How do I use Z-Order correctly

Get help using Construct 2

Post » Fri Sep 09, 2016 12:28 pm

Hi everybody,

Just a quick question about Z-Order.. Initially I use the Z-order bar to order my sprites on the layout. When I destroy a sprite, and create a new version of it, it does not use the same defined Z-Order but it appears on top of the other sprit(s).. Is this normal behaviour?

Do I have to z-order my new create objects manually every time?
B
6
S
2
Posts: 5
Reputation: 515

Post » Fri Sep 09, 2016 1:08 pm

Newly created objects land in front of all the other objects on the same layer. All objects on layers above the spawn-layer show in front. Z-order is the order of objects on a specific layer. But also the layers have a (kinda) Z-order. Layer on top shows in front.

So, first, you got to create them on the right layer. The create action will ask you the layer. And that layer has to be on the right place in the layers list.
Secondly, if you want the newly created object behind an existing object, then yes you have to adjust the Z-order. But that is only possible for objects on the same layer.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Sep 09, 2016 1:10 pm

99Instances2Go wrote:Newly created objects land in front of all the other objects on the same layer. All objects on layers above the spawn-layer show in front. Z-order is the order of objects on a specific layer. But also the layers have a (kinda) Z-order. Layer on top shows in front.

So, first, you got to create them on the right layer. The create action will ask you the layer. And that layer has to be on the right place in the layers list.
Secondly, if you want the newly created object behind an existing object, then yes you have to adjust the Z-order. But that is only possible for objects on the same layer.


Thanks, this means my assumption was correct. I wonder if the new command 'Sort z order' can be of some use here :)
B
6
S
2
Posts: 5
Reputation: 515

Post » Fri Sep 09, 2016 1:41 pm

You have the bring in front/back in the sprite actions. They might be easyer.

For the system Z-order action, you need to give instances an instance variable, and give each a value. Z-order will sort depending on that value. Hence, it only orders instances. Newly created objects need a value givven to that instance variable.

Unless you have access to families. Then you can use a familie variable to sort.

Renember that you can not read from a newly created object until the next top-level-event. Meanig, you can NOT use the sort action in the same sub level as the creation action.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Sep 11, 2016 5:51 am

Thank you all for the answers, they where very helpful to me :)
B
6
S
2
Posts: 5
Reputation: 515


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 37 guests