How do I control z-order in isometric map

Get help using Construct 2

Post » Sun Mar 02, 2014 8:32 pm

I intend to create a game using isometric graphics. When I was planning the game, I noticed that I'll have trouble to control the order of objects when they are spawned because the player can added them anywhere on the map. Someone would have an idea of how to make the objects staying in the correct order regardless of the sequence in which they are placed on the map?

Thanks
B
73
S
13
G
3
Posts: 994
Reputation: 7,504

Post » Sun Mar 02, 2014 9:02 pm

Put all sprites on your map in a family. Then make a function you call everytime the player changed something on the map:
foreach spritefamily
ordered by spritefamily.Y ascending
Spritefamily move to top of layer
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Sun Mar 02, 2014 9:30 pm

Hi @Rabenmutter. Thanks for your help. I'll try it and then return to tell.
B
73
S
13
G
3
Posts: 994
Reputation: 7,504

Post » Sun Mar 02, 2014 10:35 pm

@Rabenmutter: Sometime it works, sometimes not. An example: I'm including objects and the order it's right until insert the third one. In the next inclusion, objects in the wrong order appears corrected. It is a very strange behavior. I'm attach the capx so you can view it and show me what I can doing wrong. Thank you.

https://www.dropbox.com/s/5xshuvuyp6q6ngw/test.capx
Last edited by RBuster on Sun Mar 02, 2014 11:48 pm, edited 1 time in total.
B
73
S
13
G
3
Posts: 994
Reputation: 7,504

Post » Sun Mar 02, 2014 11:13 pm

Thanks, that was exactly what I was looking for too. :)
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Mon Mar 03, 2014 12:04 am

Hi @tunepunk. You're welcome! Unfortunately still not working 100%. I hope the @Rabenmutter can help us to fix this.
B
73
S
13
G
3
Posts: 994
Reputation: 7,504

Post » Mon Mar 03, 2014 6:27 am

@RenatoB
It doesn't work 100% because the newly created object can't be picked in the function.
The solution is to either add a wait 0 before calling zorder or just run it every tick.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Mon Mar 03, 2014 6:27 am

Create a "Wait 0 " action right before you call zorder().
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Mar 03, 2014 10:54 am

I was trying this out but it has some flaws, since it only works for objects within the family, ie, particles, bullets etc that are not "sprites" won't get ordered correctly. There must be some workaround for this. Is there any way to set the zIndex to a specific number depending on the objects y position? I also think sorting all objects in a sprite intense layout every tick will be quite heavyweight calculations wise.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Mon Mar 03, 2014 12:07 pm

R0J0hound wrote:@RenatoB
It doesn't work 100% because the newly created object can't be picked in the function.
The solution is to either add a wait 0 before calling zorder or just run it every tick.


Thanks for the explanation, @R0J0hound. I fixed it.

Rabenmutter wrote:Create a "Wait 0 " action right before you call zorder().


Thank you for this nice solution, @Rabenmutter.
B
73
S
13
G
3
Posts: 994
Reputation: 7,504

Next

Return to How do I....?

Who is online

Users browsing this forum: Magistross, tarek2 and 2 guests