onedayitwillmake Posted September 25, 2013 Share Posted September 25, 2013 Trying to find out the best way to, remove a sprite.I notice there is an add method, but I don't see an accompanying remove method for sprites. What is the correct method to remove a sprite, currently i'm calling "kill" (my sprites are created using the GameObjectFactory), that doesn't seem to completely remove it, only stop drawing / updating it? Is this correct? If so what is the right way to go about removing a sprite Link to comment Share on other sites More sharing options...
rich Posted September 25, 2013 Share Posted September 25, 2013 You know that's a very good point I have just added a Sprite.destroy function to wrap it up, but here is how you could do it in the meantime:sprite.kill();if (sprite.group){ sprite.group.remove(sprite);}else if (sprite.parent){ sprite.parent.removeChild(sprite);} Link to comment Share on other sites More sharing options...
Hsaka Posted September 25, 2013 Share Posted September 25, 2013 Hello, when you kill a sprite, do the events that are attached to it such as the events.onInputDown get disposed automatically or do they need to be manually destroyed? Link to comment Share on other sites More sharing options...
Jorge Posted September 27, 2013 Share Posted September 27, 2013 Hello, when you kill a sprite, do the events that are attached to it such as the events.onInputDown get disposed automatically or do they need to be manually destroyed?That's a really interesting question. Link to comment Share on other sites More sharing options...
onedayitwillmake Posted October 12, 2013 Author Share Posted October 12, 2013 I can't seem to find the destroy function on the dev branch, is it no longer being added?How do we handle removing the inputs, previously I was doing this if( this._view.input ) { this._view.input.destroy(); } this._view.kill();However this leads to a memory leak after the game is running for a prolonged period of time.I'll try the work around above for now though Link to comment Share on other sites More sharing options...
rich Posted October 12, 2013 Share Posted October 12, 2013 I did put this back in but it's not yet pushed - keep a watch on the github repo, it'll be in the next push I do. Link to comment Share on other sites More sharing options...
Recommended Posts