mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Display Objects now clean-up their children properly on destroy.
This commit is contained in:
@@ -204,30 +204,25 @@ Phaser.BitmapText.prototype.postUpdate = function () {
|
||||
*/
|
||||
Phaser.BitmapText.prototype.destroy = function() {
|
||||
|
||||
if (this.filters)
|
||||
{
|
||||
this.filters = null;
|
||||
}
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
this.parent.remove(this);
|
||||
}
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
this.filters = null;
|
||||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
if (this.children.length > 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
this.removeChild(this.children[0]);
|
||||
}
|
||||
while (this.children.length > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -384,6 +384,13 @@ Phaser.Image.prototype.destroy = function() {
|
||||
this.input.destroy();
|
||||
}
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+10
-6
@@ -10,6 +10,7 @@
|
||||
* Here is a compatibility table showing the available default fonts across different mobile browsers: http://www.jordanm.co.uk/tinytype
|
||||
*
|
||||
* @class Phaser.Text
|
||||
* @extends PIXI.Text
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {number} x - X position of the new text object.
|
||||
@@ -170,7 +171,6 @@ Phaser.Text.prototype.update = function() {
|
||||
*/
|
||||
Phaser.Text.prototype.postUpdate = function () {
|
||||
|
||||
// Fixed to Camera?
|
||||
if (this._cache[7] === 1)
|
||||
{
|
||||
this.position.x = this.game.camera.view.x + this.cameraOffset.x;
|
||||
@@ -184,11 +184,6 @@ Phaser.Text.prototype.postUpdate = function () {
|
||||
*/
|
||||
Phaser.Text.prototype.destroy = function () {
|
||||
|
||||
if (this.filters)
|
||||
{
|
||||
this.filters = null;
|
||||
}
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
this.parent.remove(this);
|
||||
@@ -206,9 +201,18 @@ Phaser.Text.prototype.destroy = function () {
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
this.filters = null;
|
||||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -288,9 +288,18 @@ Phaser.TileSprite.prototype.destroy = function() {
|
||||
|
||||
this.events.destroy();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.removeChild(this.children[i]);
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
this.filters = null;
|
||||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user