spinnerbox Posted April 3, 2015 Share Posted April 3, 2015 How can I remove child from a group but I don't want it deleted or killed from stage? I keep all my screen objects in a group called screenObject for fading in. Then I have another group called cardGroup which keeps only the card sprites. I want to remove just two specific card sprites from cardGroup. I do this cardGroup.remove(card1, false);cardGroup.remove(card2, false); But it removes the object from stage as well. What do I do wrong? Or what to do? Link to comment Share on other sites More sharing options...
CtlAltDel Posted April 3, 2015 Share Posted April 3, 2015 Add them to another group or the world. game.add.existing(card1) spinnerbox 1 Link to comment Share on other sites More sharing options...
spinnerbox Posted April 3, 2015 Author Share Posted April 3, 2015 Yeah. It works. Just wanted to know, are my cards still live after I change state? Because game.add is game-wide Phaser.GameObjectFactory object. I mean it is same for all game states. There will be dangling sprites in memory I suppose Link to comment Share on other sites More sharing options...
CtlAltDel Posted April 3, 2015 Share Posted April 3, 2015 I presume the stage is cleared between states. Never actually checked. Link to comment Share on other sites More sharing options...
spinnerbox Posted April 3, 2015 Author Share Posted April 3, 2015 Haha, it seems remove() function also removes the cards from screenObjects group too Edited: I cannot add sprites in two groups at the same time? Cards are not added in screenObjects group. Link to comment Share on other sites More sharing options...
CtlAltDel Posted April 3, 2015 Share Posted April 3, 2015 Phaser uses a scenegraph (or rather PIXI does), and by definition a sprite can only be in one place in a scenegraph. spinnerbox 1 Link to comment Share on other sites More sharing options...
Yashar Posted April 23, 2021 Share Posted April 23, 2021 how to remove last child from group in phaser 2 ?? or how to remove child by id from group ?? Link to comment Share on other sites More sharing options...
Recommended Posts