Skip to content

How to control occlusion for 2D shapes? #446

Answered by asny
Bathtor asked this question in Q&A
Discussion options

You must be logged in to vote

You can use z to define the order of your 2D shapes, but I would not recommend it. The problem is that the z value only makes sense relative to other shapes. So imagine you have a large application with layers at z index 1, 4, 5, 6, 7, 100, 101, 102, 103, 104 and 1000. You don't have this nice list, because these shapes are created at different places in the code. Now you want to render a new shape, that should render at exactly the right place in the order, so you need a correct z index. That is not easy to find and not super fun, trust me I've tried.

Instead, I'd recommend using the order of rendering, exactly as @Nevsden originally suggested. That way, it's just a matter of rendering y…

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Bathtor
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #438 on February 23, 2024 15:04.