Jump to content

How to sort groups by z?


Recommended Posts

Changing the z property will have no effect, this is for internally storing the order of the children of an object. The actual order is determined by an object's children property, which is an array. The objects in this array are rendered in order from first to last (back to front) - luckily there are some handy methods in the Group object such as swap which will swap two children around.


The key is to know what the parent of the two groups is - I suspect if they've both just been added as is, it will be game.world, so the following should work:

game.world.swap(group1, group2);

There are other methods like bringToFront, sendToBack, moveUp and moveDown which will all let you control the order of an object's children.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...