megmut Posted October 5, 2015 Share Posted October 5, 2015 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: 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); 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 More sharing options...
megmut Posted October 6, 2015 Author Share Posted October 6, 2015 Bump Link to comment Share on other sites More sharing options...
megmut Posted October 6, 2015 Author Share Posted October 6, 2015 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 More sharing options...
Recommended Posts