How do I set Z-order to a specific number for a sprite

0 favourites
  • 6 posts
From the Asset Store
The collection includes pre-categorized selections that can be the definitive tone setting backdrop to gameplay.
  • Hi. I am displaying an isometric tilemap... with the (0,0) tile (on the grid) mapped top centre. This means that the required Z-order for any particular tile representing a grid location is given by Z=x+y... So each 'diagonal on the grid, horizontal on the screen' row will have tiles with the same Zorder value - they cannot overlap so that is fine and normal for iso.

    If necessary then I could generate unique Zorder values across the 'width' using (x+y)*100 + x or something similar.... anyway...

    If I replace a tile somewhere then I could just set the Zorder for the newly created tile as I know what value I want to give it.... but Construct2 does not seem to let me do that ?

    Is there any way to avoid having to loop over the entire grid everytime I replace a single tile - the visible grid is 20x20, so this a non-trivial nested pair.

    I was expecting to find a settable property: Family.Zorder = <value> and be able to just set it myself! Please advise how I can do this.

    One possible alternative approach is I could create 40 layers specifically for the iso tiles - but would this be hugely inefficient when the layers are drawn ?

    Cheers

  • By "replacing" a tile, are you saying that you're destroying one and then creating a new one in its place? If that's the case, you should be able to use the "Move to object" action under "Z Order" after creating your new tile, but before destroying the old one, using said action to place the new tile just in front of or behind the old one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Linkman thank you... that's worth trying. It will produce unnecessarily messy code if changing a load though, also will constrain the two things to happen close in time. I'd prefer to be able to set Zorder explicitly - from your reply I take it that isn't possible ?

    Would there be any problems with the many layers approach (I'm now thinking of doubling tile dimensions and having only 20 layers...

    Your thoughts appreciated.

  • As far as I'm aware, you can't explicitly set Z-order -- the reasons for this, I couldn't answer.

    Using lots of layers should perform fine, though working with that many could become bothersome.

  • Your question give me an idea. I don't know how is your system works, but i wrote a simple z-order solution for isometric grid systems.

    https://www.scirra.com/tutorials/1165/z-ordering-on-a-isometric-grid

  • Thank you. LinkMan I'll do a multiple layers experiment... mrcgkh I'll try out once I get latest Construct2, I don't normally get the betas.

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