Ninjadoodle Posted April 27, 2018 Share Posted April 27, 2018 Hi @enpu I'm trying to remove an explosion animation when it's finished playing. Just want to double check whether the code below completely gets rid of it ... game.createClass('Explosion', { init: function(x, y) { this.sprite = game.Animation.fromTextures('explosion'); this.sprite.position.set(x, y); this.sprite.anchorCenter(); this.sprite.loop = false; this.sprite.speed = 60; this.sprite.play(); this.sprite.addTo(game.scene.bg); this.sprite.onComplete = function() { this.remove(); } } }); Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted April 27, 2018 Share Posted April 27, 2018 @Ninjadoodle Looking good to me. remove function removes the sprite from it's parent, so it doesn't get rendered anymore (you should see the "draws" number dropping down on the debug panel) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.