How do I control the Z order of created objects?

Get help using Construct 2

Post » Tue Jun 10, 2014 5:20 pm

Hey there.

I'm currently developing a prototype for a tower defense game similar to Plants vs Zombies. Right now, tower placement and deletion works, as well as a basic shooter unit. However, I can't seem to figure out how to control the Z order of the units I create on the board.

As expected, more recent units stay on top.

Image

I tried making the Z order be equivalent to their Y position on the board, but I can't seem to manipulate it further than moving higher or lower. None of the methods I tried to use worked. How could I make it so that higher units always stay on the back without a large amount of unnecessary layers for each lane? (The board may be much larger than this in later stages)

Thanks in advance.

EDIT: Oh yes, here's the prototype's .capx with my original attempt. The hitbox object is due to the unit's actual collision polygon being the tile, thus not being able to check for sprite excess.
You do not have the required permissions to view the files attached to this post.
B
5
S
2
G
1
Posts: 4
Reputation: 608

Post » Tue Jun 10, 2014 10:55 pm

The solution is so simple, just use for each (ordered) based on it's Y position
I edited yours capx
You do not have the required permissions to view the files attached to this post.
ImageImage
B
115
S
51
G
24
Posts: 790
Reputation: 23,505

Post » Wed Jun 11, 2014 12:01 am

Oh wow! That's a pretty clever use of the 'for each' condition. Didn't notice you could pick an order for it.

Thanks for the help, it works perfectly! =)
B
5
S
2
G
1
Posts: 4
Reputation: 608


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests