Sprites now have preDestroy method, which is called automatically by destroy. The method destroys the Animation component, unregistering the remove event in the process and freeing-up resources. Fix #4051

This commit is contained in:
Richard Davey 2018-09-25 15:11:15 +01:00
parent e94d92518d
commit 2812bff0ee
2 changed files with 15 additions and 0 deletions

View file

@ -9,6 +9,7 @@
### Bug Fixes
* GameObjects added to and removed from Containers no longer listen for the `shutdown` event at all (thanks Vitali)
* Sprites now have `preDestroy` method, which is called automatically by `destroy`. The method destroys the Animation component, unregistering the `remove` event in the process and freeing-up resources. Fix #4051 (thanks @Aveyder)
### Examples, Documentation and TypeScript

View file

@ -153,6 +153,20 @@ var Sprite = new Class({
// Extra Sprite data is added here
return data;
},
/**
* Handles the pre-destroy step for the Sprite, which removes the Animation component.
*
* @method Phaser.GameObjects.Sprite#preDestroy
* @private
* @since 3.14.0
*/
preDestroy: function ()
{
this.anims.destroy();
this.anims = undefined;
}
});