Display Objects now clean-up their children properly on destroy.

This commit is contained in:
photonstorm
2014-02-21 13:25:08 +00:00
parent dd8a393bc9
commit a61d030256
5 changed files with 43 additions and 20 deletions
+8
View File
@@ -14,6 +14,7 @@
* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.
*
* @constructor
* @extends PIXI.Sprite
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} x - The x coordinate (in world space) to position the Sprite at.
* @param {number} y - The y coordinate (in world space) to position the Sprite at.
@@ -516,6 +517,13 @@ Phaser.Sprite.prototype.destroy = function() {
this.events.destroy();
}
var i = this.children.length;
while (i--)
{
this.removeChild(this.children[i]);
}
this.alive = false;
this.exists = false;
this.visible = false;