Sprite, set Z order right.

Get help using Construct 2

Post » Thu May 02, 2013 5:11 am

Do you feel my pain?

What would be a good approach? Objects in this game move, so how would I keep them in the right order?

Right now I am thinking of some hackish, loop that checks all objecs Y position.

B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Thu May 02, 2013 8:40 am

I'm using this system :
Just add every objects in a family (eg "All")

System -> For each All order by All.Y ascending -> All move to top of the layer.

B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Thu May 02, 2013 11:30 am

I'm always a little iffy about using For Each too much. If you have a lot of stuff onscreen, I can imagine it causing slowdown at some point.

The way I do it relies on collisions instead, also using a family for all objects.

+"Sprite" overlaps "All"
+Sub: Sprite.Y > All.Y
-Sprite - move in front of All
+Sub: Sprite.Y < All.Y
-Sprite - move behind All

That way you only check and change the Z order when it's actually necessary (when things collide).

Though you do have to have these events for every object that might change it's Z order.inkBot2013-05-02 11:34:01
B
73
S
20
G
10
Posts: 524
Reputation: 9,896


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests