Beat 'em up z order question

Get help using Construct 2

Post » Mon Feb 17, 2014 4:10 pm

That wouldn't work because I want the characters on the front side to be in front of it and all of the characters still need to keep the relative z order. I still haven't solved this problem. Seems like a tricky one to me. :(
Image
B
20
S
4
Posts: 382
Reputation: 2,984

Post » Mon Feb 17, 2014 4:20 pm

Did you try using instance vatiable to set Y value for current sprite and then sort Z order? something like that

create instance variable "z" for family Boxes

then
every tick -> Sprite | Set "z" to self.Y

System: For each Boxes order by Boxes.Z ascending > Boxes | move to top of layer

this way you can specify Z order for every single object using

every tick -> Sprite | Set "z" to self.Y+15
or
every tick -> Sprite | Set "z" to self.Y-150
or whatever you like.

Even if sprites image point will have Y=50 you can set this Sprites Z to let say 150 using Set "z" to self.Y+100
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Mon Feb 17, 2014 6:04 pm

For each sprite, use their Y position to project the X intercept coordinate of the force field. If Sprite.X is less than the projected X, move it to a layer above the force field. Otherwise, move it to a layer below.

Demo
Capxzatyka2014-02-17 19:06:46
B
64
S
19
G
8
Posts: 341
Reputation: 12,185

Post » Mon Feb 17, 2014 6:57 pm

Thanks! I'm going to try this!
Image
B
20
S
4
Posts: 382
Reputation: 2,984

Post » Mon Feb 17, 2014 7:38 pm

@zatyka In order to keep my fragile z order intact, I am trying to modify the events you shared with me to move ONLY the forcefield. Here's what the events currently look like:



If I moved the individual sprites to the layer above or below or even move them up and down within their own layer, it throws the whole z order off. Can you see what I'd need to change in my current code to make this work? Thanks so much!
Image
B
20
S
4
Posts: 382
Reputation: 2,984

Post » Tue Feb 18, 2014 4:22 am

Thanks everyone for your help but I ended up making an entirely different forcefield effect in Spriter. I think what I was trying to do may be impossible because you had to have both ordering by y and by x and the two were, inevitably, in conflict. Here's a screenshot of the alternative effect I came up with.

PSI2014-02-18 04:24:13
Image
B
20
S
4
Posts: 382
Reputation: 2,984

Post » Sat Dec 05, 2015 7:37 pm

For those interested, I solved it in this way:

If Sprite1 Is Overlapping Sprite2:
_____If Sprite1.Y > Sprite2.Y:
___________Sprite 1 -> (Z Order) Move to Object -> "IN FRONT", Sprite 2
_____Else
___________same but "BEHIND"

So the computer will just make that calculations when overlapping and not every tick. I don't know if it saves speed but I guess.

It's usefull if the sprites has the origin point in the same place (example: bottom). If you have objects with differents origin points (ex: Sprite 1 -> bottom, Sprite 2 --> center), you can create blank sprites with equal origin points and "pin" them to the sprites you have. Or simply use another points (Image Points) in the same sprite for this matter.
B
6
Posts: 1
Reputation: 252

Previous

Return to How do I....?

Who is online

Users browsing this forum: 8tomo8, brunopalermo, wertt22 and 8 guests