Jump to content

Nested Group Not Allowing Z Sort


megmut
 Share

Recommended Posts

Sorry for the double post. I can't seem to change the Z sort of groups when they are nested inside another group. Am I doing something wrong? Does phaser not allow this?

 

Here's an example (sudo):

Make object {  group1: this.game.add.group(),  group2: this.game.add.group(),  group3: this.game.add.group(),  group4: this.game.add.group(),  group5: this.game.add.group}Render all elements and put in group {  group1.add(all artwork)}Set group z{  objectGroup.group1.z = 9;  objectGroup.group2.z = 8;  objectGroup.group3.z = 7;  objectGroup.group4.z = 6;  objectGroup.group5.z = 5;}

This works fine, as you can see here:

 

post-16587-0-72438800-1444055727.png

 

However, when I try to add the object containing my groups to a parent group, the sort seems to now work :(

groupMain.add(objectGroup.group1);groupMain.add(objectGroup.group2);groupMain.add(objectGroup.group3);groupMain.add(objectGroup.group4);groupMain.add(objectGroup.group5);

post-16587-0-69391800-1444055877.png

 

I've tried using this.game.bringToTop(objectGroup.groupX), as well as this.game.bringToTop(groupMain). I'm calling this.world.sort('z') from the update loop just to make sure that it's working correctly now. I will move it out of there once this issue has resolved.

 

Thanks

 

Nick 

Link to comment
Share on other sites

Fixed thanks to CtlAltDel and jmp909. 

 

I was sorting the world of groups, but not the sub group.. my update loop now looks like this:

update: function() {    this.world.sort('z');    parentGroup.sort('z');},
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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