diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 64ed31d..9e96a87 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -547,9 +547,21 @@ /** * Destroys the container - * + * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well */ -Container.prototype.destroy = function () +Container.prototype.destroy = function (destroyChildren) { + DisplayObject.prototype.destroy.call(this); + + if(destroyChildren) + { + for (var i = 0, j = this.children.length; i < j; ++i) + { + this.children[i].destroy(); + } + } + + this.removeChildren(); + this.children = null; }; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 64ed31d..9e96a87 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -547,9 +547,21 @@ /** * Destroys the container - * + * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well */ -Container.prototype.destroy = function () +Container.prototype.destroy = function (destroyChildren) { + DisplayObject.prototype.destroy.call(this); + + if(destroyChildren) + { + for (var i = 0, j = this.children.length; i < j; ++i) + { + this.children[i].destroy(); + } + } + + this.removeChildren(); + this.children = null; }; diff --git a/src/core/math/shapes/Polygon.js b/src/core/math/shapes/Polygon.js index 07a9e31..a31a031 100644 --- a/src/core/math/shapes/Polygon.js +++ b/src/core/math/shapes/Polygon.js @@ -4,9 +4,9 @@ /** * @class * @memberof PIXI - * @param points* {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, + * @param points {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be - * all the points of the polygon e.g. `new Polygon(new Point(), new Point(), ...)`, or the + * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the * arguments passed can be flat x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are * Numbers. */ @@ -18,7 +18,7 @@ points = Array.prototype.slice.call(arguments); } - //if this is a flat array of numbers, convert it to points + //if this is an array of points, convert it to a flat array of numbers if (points[0] instanceof Point) { var p = []; @@ -35,7 +35,7 @@ /** * An array of the points of this polygon * - * @member {Point[]} + * @member {Array} */ this.points = points; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 64ed31d..9e96a87 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -547,9 +547,21 @@ /** * Destroys the container - * + * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well */ -Container.prototype.destroy = function () +Container.prototype.destroy = function (destroyChildren) { + DisplayObject.prototype.destroy.call(this); + + if(destroyChildren) + { + for (var i = 0, j = this.children.length; i < j; ++i) + { + this.children[i].destroy(); + } + } + + this.removeChildren(); + this.children = null; }; diff --git a/src/core/math/shapes/Polygon.js b/src/core/math/shapes/Polygon.js index 07a9e31..a31a031 100644 --- a/src/core/math/shapes/Polygon.js +++ b/src/core/math/shapes/Polygon.js @@ -4,9 +4,9 @@ /** * @class * @memberof PIXI - * @param points* {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, + * @param points {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be - * all the points of the polygon e.g. `new Polygon(new Point(), new Point(), ...)`, or the + * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the * arguments passed can be flat x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are * Numbers. */ @@ -18,7 +18,7 @@ points = Array.prototype.slice.call(arguments); } - //if this is a flat array of numbers, convert it to points + //if this is an array of points, convert it to a flat array of numbers if (points[0] instanceof Point) { var p = []; @@ -35,7 +35,7 @@ /** * An array of the points of this polygon * - * @member {Point[]} + * @member {Array} */ this.points = points; diff --git a/src/deprecation.js b/src/deprecation.js index ec346af..0543d0b 100644 --- a/src/deprecation.js +++ b/src/deprecation.js @@ -19,7 +19,7 @@ get: function () { window.console.warn('You do not need to use a PIXI Stage any more, you can simply render any container.'); - return new core.Container(); + return core.Container; } }, @@ -27,7 +27,7 @@ get: function () { window.console.warn('DisplayObjectContainer has been shortened to Container, please use Container from now on'); - return new core.Container(); + return core.Container; } }, @@ -35,7 +35,7 @@ get: function () { window.console.warn('The Strip class has been renamed to Mesh, please use Mesh from now on'); - return new mesh.Mesh(texture); + return mesh.Mesh; } } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 64ed31d..9e96a87 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -547,9 +547,21 @@ /** * Destroys the container - * + * @param destroyChildren {boolean} if set to true, all the children will have their destroy method called as well */ -Container.prototype.destroy = function () +Container.prototype.destroy = function (destroyChildren) { + DisplayObject.prototype.destroy.call(this); + + if(destroyChildren) + { + for (var i = 0, j = this.children.length; i < j; ++i) + { + this.children[i].destroy(); + } + } + + this.removeChildren(); + this.children = null; }; diff --git a/src/core/math/shapes/Polygon.js b/src/core/math/shapes/Polygon.js index 07a9e31..a31a031 100644 --- a/src/core/math/shapes/Polygon.js +++ b/src/core/math/shapes/Polygon.js @@ -4,9 +4,9 @@ /** * @class * @memberof PIXI - * @param points* {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, + * @param points {Point[]|number[]|...Point|...number} This can be an array of Points that form the polygon, * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be - * all the points of the polygon e.g. `new Polygon(new Point(), new Point(), ...)`, or the + * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the * arguments passed can be flat x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are * Numbers. */ @@ -18,7 +18,7 @@ points = Array.prototype.slice.call(arguments); } - //if this is a flat array of numbers, convert it to points + //if this is an array of points, convert it to a flat array of numbers if (points[0] instanceof Point) { var p = []; @@ -35,7 +35,7 @@ /** * An array of the points of this polygon * - * @member {Point[]} + * @member {Array} */ this.points = points; diff --git a/src/deprecation.js b/src/deprecation.js index ec346af..0543d0b 100644 --- a/src/deprecation.js +++ b/src/deprecation.js @@ -19,7 +19,7 @@ get: function () { window.console.warn('You do not need to use a PIXI Stage any more, you can simply render any container.'); - return new core.Container(); + return core.Container; } }, @@ -27,7 +27,7 @@ get: function () { window.console.warn('DisplayObjectContainer has been shortened to Container, please use Container from now on'); - return new core.Container(); + return core.Container; } }, @@ -35,7 +35,7 @@ get: function () { window.console.warn('The Strip class has been renamed to Mesh, please use Mesh from now on'); - return new mesh.Mesh(texture); + return mesh.Mesh; } } diff --git a/src/index.js b/src/index.js index da8c001..1ba15c8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ var core = require('./core'); +extendCore(require('./core/math')); extendCore(require('./extras')); extendCore(require('./mesh')); extendCore(require('./filters'));