diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/graphics/GraphicsData.js b/src/core/graphics/GraphicsData.js index 44d8d34..a64fadc 100644 --- a/src/core/graphics/GraphicsData.js +++ b/src/core/graphics/GraphicsData.js @@ -82,3 +82,7 @@ this.shape ); }; + +GraphicsData.prototype.destroy = function () { + ths.shape = null; +}; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/graphics/GraphicsData.js b/src/core/graphics/GraphicsData.js index 44d8d34..a64fadc 100644 --- a/src/core/graphics/GraphicsData.js +++ b/src/core/graphics/GraphicsData.js @@ -82,3 +82,7 @@ this.shape ); }; + +GraphicsData.prototype.destroy = function () { + ths.shape = null; +}; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index c95d294..0c4ead6 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -506,8 +506,8 @@ /** * Destroys this sprite and optionally its texture * - * @param destroyTexture {boolean} Should it destroy the current texture of the sprite as well - * @param destroyBaseTexture {boolean} Should it destroy the base texture of the sprite as well + * @param [destroyTexture=false] {boolean} Should it destroy the current texture of the sprite as well + * @param [destroyBaseTexture=false] {boolean} Should it destroy the base texture of the sprite as well */ Sprite.prototype.destroy = function (destroyTexture, destroyBaseTexture) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/graphics/GraphicsData.js b/src/core/graphics/GraphicsData.js index 44d8d34..a64fadc 100644 --- a/src/core/graphics/GraphicsData.js +++ b/src/core/graphics/GraphicsData.js @@ -82,3 +82,7 @@ this.shape ); }; + +GraphicsData.prototype.destroy = function () { + ths.shape = null; +}; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index c95d294..0c4ead6 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -506,8 +506,8 @@ /** * Destroys this sprite and optionally its texture * - * @param destroyTexture {boolean} Should it destroy the current texture of the sprite as well - * @param destroyBaseTexture {boolean} Should it destroy the base texture of the sprite as well + * @param [destroyTexture=false] {boolean} Should it destroy the current texture of the sprite as well + * @param [destroyBaseTexture=false] {boolean} Should it destroy the base texture of the sprite as well */ Sprite.prototype.destroy = function (destroyTexture, destroyBaseTexture) { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index cb24968..5c302c1 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -78,7 +78,6 @@ texture.trim = new math.Rectangle(); Sprite.call(this, texture); - this.text = text; this.style = style; } @@ -582,7 +581,7 @@ /** * Destroys this text object. * - * @param destroyBaseTexture {boolean} whether to destroy the base texture as well + * @param [destroyBaseTexture=true] {boolean} whether to destroy the base texture as well */ Text.prototype.destroy = function (destroyBaseTexture) { @@ -590,5 +589,7 @@ this.context = null; this.canvas = null; + this._style = null; + this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/graphics/GraphicsData.js b/src/core/graphics/GraphicsData.js index 44d8d34..a64fadc 100644 --- a/src/core/graphics/GraphicsData.js +++ b/src/core/graphics/GraphicsData.js @@ -82,3 +82,7 @@ this.shape ); }; + +GraphicsData.prototype.destroy = function () { + ths.shape = null; +}; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index c95d294..0c4ead6 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -506,8 +506,8 @@ /** * Destroys this sprite and optionally its texture * - * @param destroyTexture {boolean} Should it destroy the current texture of the sprite as well - * @param destroyBaseTexture {boolean} Should it destroy the base texture of the sprite as well + * @param [destroyTexture=false] {boolean} Should it destroy the current texture of the sprite as well + * @param [destroyBaseTexture=false] {boolean} Should it destroy the base texture of the sprite as well */ Sprite.prototype.destroy = function (destroyTexture, destroyBaseTexture) { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index cb24968..5c302c1 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -78,7 +78,6 @@ texture.trim = new math.Rectangle(); Sprite.call(this, texture); - this.text = text; this.style = style; } @@ -582,7 +581,7 @@ /** * Destroys this text object. * - * @param destroyBaseTexture {boolean} whether to destroy the base texture as well + * @param [destroyBaseTexture=true] {boolean} whether to destroy the base texture as well */ Text.prototype.destroy = function (destroyBaseTexture) { @@ -590,5 +589,7 @@ this.context = null; this.canvas = null; + this._style = null; + this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 3d6c9c2..63dd199 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -239,8 +239,8 @@ this.baseTexture.destroy(); } - this.baseTexture.removeListener('update', this.onBaseTextureUpdated, this); - this.baseTexture.removeListener('loaded', this.onBaseTextureLoaded, this); + this.baseTexture.off('update', this.onBaseTextureUpdated); + this.baseTexture.off('loaded', this.onBaseTextureLoaded); this.valid = false; }; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e3d5054..9c82d6c 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -549,13 +549,13 @@ /** * Destroys the container - * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well + * @param [destroyChildren=false] {boolean} if set to true, all the children will have their destroy method called as well */ Container.prototype.destroy = function (destroyChildren) { DisplayObject.prototype.destroy.call(this); - if(destroyChildren) + if (destroyChildren) { for (var i = 0, j = this.children.length; i < j; ++i) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index ccf2fa0..9d6b4bf 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -454,12 +454,12 @@ this.scale = null; this.pivot = null; + this.parent = null; + this._bounds = null; this._currentBounds = null; this._mask = null; this.worldTransform = null; this.filterArea = null; - - this.listeners = null; }; diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ba694b9..6dae5c1 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1156,3 +1156,17 @@ return data; }; + +Graphics.prototype.destroy = function () { + Container.prototype.destroy.apply(this, arguments); + + for (var i = 0; i < this.graphicsData.length; ++i) { + this.graphicsData[i].destroy(); + } + + this.graphicsData = null; + + this.currentPath = null; + this._webgl = null; + this._localBounds = null; +}; diff --git a/src/core/graphics/GraphicsData.js b/src/core/graphics/GraphicsData.js index 44d8d34..a64fadc 100644 --- a/src/core/graphics/GraphicsData.js +++ b/src/core/graphics/GraphicsData.js @@ -82,3 +82,7 @@ this.shape ); }; + +GraphicsData.prototype.destroy = function () { + ths.shape = null; +}; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index c95d294..0c4ead6 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -506,8 +506,8 @@ /** * Destroys this sprite and optionally its texture * - * @param destroyTexture {boolean} Should it destroy the current texture of the sprite as well - * @param destroyBaseTexture {boolean} Should it destroy the base texture of the sprite as well + * @param [destroyTexture=false] {boolean} Should it destroy the current texture of the sprite as well + * @param [destroyBaseTexture=false] {boolean} Should it destroy the base texture of the sprite as well */ Sprite.prototype.destroy = function (destroyTexture, destroyBaseTexture) { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index cb24968..5c302c1 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -78,7 +78,6 @@ texture.trim = new math.Rectangle(); Sprite.call(this, texture); - this.text = text; this.style = style; } @@ -582,7 +581,7 @@ /** * Destroys this text object. * - * @param destroyBaseTexture {boolean} whether to destroy the base texture as well + * @param [destroyBaseTexture=true] {boolean} whether to destroy the base texture as well */ Text.prototype.destroy = function (destroyBaseTexture) { @@ -590,5 +589,7 @@ this.context = null; this.canvas = null; + this._style = null; + this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 3d6c9c2..63dd199 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -239,8 +239,8 @@ this.baseTexture.destroy(); } - this.baseTexture.removeListener('update', this.onBaseTextureUpdated, this); - this.baseTexture.removeListener('loaded', this.onBaseTextureLoaded, this); + this.baseTexture.off('update', this.onBaseTextureUpdated); + this.baseTexture.off('loaded', this.onBaseTextureLoaded); this.valid = false; }; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index b323184..12163cf 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -144,10 +144,7 @@ { if (this.source && this.source._pixiId) { - utils.BaseTextureCache[ this.source._pixiId ] = null; delete utils.BaseTextureCache[ this.source._pixiId ]; - - this.source._pixiId = null; delete this.source._pixiId; }