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

Get help using Construct 2

Post » Mon Sep 15, 2014 2:57 pm

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
B
9
S
3
Posts: 23
Reputation: 646

Post » Mon Sep 15, 2014 7:39 pm

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.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Tue Sep 16, 2014 8:00 am

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.
B
9
S
3
Posts: 23
Reputation: 646

Post » Tue Sep 16, 2014 12:20 pm

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.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Tue Sep 16, 2014 4:05 pm

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
B
21
S
8
G
6
Posts: 177
Reputation: 8,124

Post » Mon Sep 22, 2014 8:25 am

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.
B
9
S
3
Posts: 23
Reputation: 646


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests