Breaking the z-order law. One Group, variable z-depth.

Article by Richard Davey. Posted on 28th Mar 2016.   @phaser_

image

"When building scene tree in Phaser engine the sprites added as last are rendered on top. Unlike, for example, in Unity, you cannot change order of sprites with setting its z position. You can only set z property and sort sprites within one group.

You can try to achieve this with:

  1. making two groups (walls and gems) and tween them. But, in such case all gems will be under or above walls, depending on groups order.

  2. making one group with all the walls and gems, but to move them you will have to create 8 tweens.

There is third way which allows you to put all sprites in one group (like in 2.) and transform gems and walls at once (like in 1.)."

Read More