How do I set prior saved sprite z-index? Big trouble...

Get help using Construct 2

Post » Sat Mar 14, 2015 12:10 am

I'm probably in some huuuuuge trouble because I think this is completely impossible in C2...

I wrote a function that iterates over every terrain tile in my isometric map layout. I saved the terrain.type, terrain.zIndex, terrain.X and terrain.Y in an array and then downloaded it as JSON.

Wrote another function to load that JSON file back into the array and recreate/draw the terrain.

Now the very, very sad (for me) part...

Remember, this is an isometric layout: There is no way to re-set the original zIndexes on the terrain sprites!

I'm screwed right? :cry:
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sat Mar 14, 2015 12:33 am

The original Z indices may not be valid, but thier order may be. You can sort them and then either Move to Top or Move to Bottom, which should recreate the original order, albeit in an inefficient way.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Sat Mar 14, 2015 12:48 am

Is every zIndex unique? If not, I'm backed to screwed :cry:
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sat Mar 14, 2015 12:53 am

Z-indices are indeed unique, at least per layer. Though even if they weren't, bladedpenguin's method would likely work all the same.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Sat Mar 14, 2015 12:58 am

linkman2004 wrote:Z-indices are indeed unique, at least per layer. Though even if they weren't, bladedpenguin's method would likely work all the same.


If every sprite on same layer has a unique zIndex, I may be un-screwed ;)

I can draw each sprite in ascending order of zIndex. This should always put the next sprite in it's proper front/back orientation. I think... :?
Last edited by locohost on Sat Mar 14, 2015 1:11 am, edited 1 time in total.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sat Mar 14, 2015 1:40 am

Holy mother of Odin that worked! :D

@bladedpenguin, @linkman2004 I'll be sending you both birthday cards stuffed with cash!
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sat Mar 14, 2015 3:26 pm

Glad we could help you ^_^
B
14
S
5
G
1
Posts: 189
Reputation: 1,536


Return to How do I....?

Who is online

Users browsing this forum: BackendFreak, imhotep22 and 4 guests