phamedev Posted October 15, 2017 Share Posted October 15, 2017 Hello, 1. I created a group groupA in the game. 2. I created a sprite spriteA and added it to groupA. 3. After that I kill() spriteA and keep its reference in a pool array for later use. 4. I destroy() groupA. 5. I get the spriteA from the pool array to be used in another group and try to change its texture with loadTexture(), I get error: phaser2.8.8.js:46794 Uncaught TypeError: Cannot read property 'cache' of null at Phaser.Sprite.loadTexture (phaser2.8.8.js:46794) That doesn't happen if I don't destroy the group in step 4. Could anyone please explain what is going on and what is the right way to reuse Sprites even when their container parents are destroyed? Link to comment Share on other sites More sharing options...
samme Posted October 15, 2017 Share Posted October 15, 2017 It's because Group#destroy also destroys all children and spriteA is still a child of the group. You should remove the sprite from the group before you add it to the pool. Link to comment Share on other sites More sharing options...
Recommended Posts