Z-order and in front/behind issue

Get help using Construct 2

Post » Thu Sep 12, 2013 6:13 pm

I need some help figuring out how to get my character and NPC sprites to properly layer when they're in front and behind of each other. What I want to do is this:



Where when the red sprite is in front of the blue sprite it shows up on top, but when the red sprite is behind the blue sprite the blue sprite is on top. Working with single layers just ends up with one sprite always being on top, regardless of position:



Is the best way to handle this to cut my sprites in half at the waist with the waist-down being on a lower layer than the waist up? If I put the collision box in the lower half, the sprites should be able to line up properly:



So, that works, but I'm posting here in hopes of there being a better way, whether there's a function I didn't know about, or a behavior someone's published, or just an easier trick someone thought up.

Thanks in advance.
B
3
Posts: 5
Reputation: 181

Post » Thu Sep 12, 2013 6:39 pm

Do this:

every tick
for each dude (order by y ascending)
.. dude move to top of the layer

Should work. Depending on how many objects you have will need to be optimized :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Sep 12, 2013 6:57 pm

[QUOTE=vee41] Do this:

every tick
for each dude (order by y ascending)
.. dude move to top of the layer
[/QUOTE]


This is what I do.
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Thu Sep 12, 2013 7:01 pm

Ahh, thanks so much. Works great.
B
3
Posts: 5
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Elliott, Yahoo [Bot] and 59 guests