Ninjadoodle Posted February 12, 2018 Share Posted February 12, 2018 Hi @enpu If I remove an atlas/asset inside a scene, does it stay in memory until I leave that scene? Thank you Quote Link to comment Share on other sites More sharing options...
enpu Posted February 12, 2018 Share Posted February 12, 2018 @Ninjadoodle Good question! Asset will stay in memory as long as there is reference to it. Changing scene will usually remove all references, so in most situations yes it will stay in memory until you leave scene. game.createScene('Main', { init: function() { this.sprite = new game.Sprite('panda.png'); this.sprite.addTo(this.stage); }, mousedown: function() { game.removeAsset('panda.png'); // panda.png would still be rendered // because there is reference to the texture at // this.sprite.texture }, mouseup: function() { this.sprite.remove(); // Remove from stage this.sprite = null; // Remove reference // This would now throw error var sprite = new game.Sprite('panda.png'); sprite.addTo(this.stage); } }); Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted February 13, 2018 Author Share Posted February 13, 2018 Awesome, thanks! 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.