How do I control the Z order of created objects?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

    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.

  • The solution is so simple, just use for each (ordered) based on it's Y position

    I edited yours capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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! =)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)