bymafmaf Posted December 5, 2015 Share Posted December 5, 2015 Hi! I have a sprite which has some children. I runthis.world.bringToTop(mainSprite);and it works well. However, it applies only to children of mainSprite, not child of one of its children. For example mainSprite.child is brought to top but mainSprite.child.child doesn't.. Is it a bug or I am missing something? Link to comment Share on other sites More sharing options...
drhayes Posted December 6, 2015 Share Posted December 6, 2015 Do you have a live example we could look at? Link to comment Share on other sites More sharing options...
bymafmaf Posted December 13, 2015 Author Share Posted December 13, 2015 Sorry for late answer. I've had to change the code. But I think it's straightforward,parentSprite = this.add(0,0,'someKey');childSprite = this.add(10,10, 'anotherKey');greatChildSprite = this.add(20,20, 'differentKey');childSprite.addChild(greatChildSprite);parentSprite.addChild(childSprite);game.world.bringToTop(parentSprite); //this brings only parentSprite and childSprite to top, not greatChildSprite Link to comment Share on other sites More sharing options...
ekeimaja Posted December 13, 2015 Share Posted December 13, 2015 I assume that Phaser supports just one child element, so that's why it does not work. But I have never used child element, so I cannot say sure. Link to comment Share on other sites More sharing options...
WombatTurkey Posted December 13, 2015 Share Posted December 13, 2015 Pretty sure you have to apply the method directly to the child, not the parent. Link to comment Share on other sites More sharing options...
bymafmaf Posted December 13, 2015 Author Share Posted December 13, 2015 Why doesn't it affect all children? I mean this is really intuitive. I run function for parent and its children also run it. That principle holds for children, too. So, all sprites under first parent should run it. Link to comment Share on other sites More sharing options...
Recommended Posts