Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sandheaver |
If I have 2 overlapping sprites, how can I determine or detect which one is on top?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sandheaver |
If I have 2 overlapping sprites, how can I determine or detect which one is on top?
Reply From: | eska |
Nodes are drawn in tree-order (except for special cases such as children of YSort nodes), so lower nodes are drawn on top. In GDScript you can test this using the is_greater_than()
method:
if sprite1.is_greater_than(sprite2):
# sprite1 is on top of sprite2
pass
Thanks, that’s exactly what I needed.
sandheaver | 2018-04-04 20:14