Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group is has no children.

This commit is contained in:
photonstorm
2013-12-05 09:14:49 +00:00
parent eb3d8241ca
commit cd314cd03e
3 changed files with 14 additions and 21 deletions
+7 -1
View File
@@ -46,13 +46,16 @@ Version 1.1.4 - "Kandor" - In development
New features:
* TBC
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
Updates:
* When a Sprite is destroyed any active filters are removed as well.
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
* Phaser.Canvas.create updated to it can be given an ID as the 3rd parameter.
* Updated display/fullscreen example to reflect new full screen change.
Bug Fixes:
@@ -60,6 +63,9 @@ Bug Fixes:
* Fixed Group.scale so you can now scale a Group directly.
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group is has no children.
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
+7 -9
View File
@@ -1047,7 +1047,7 @@ Phaser.Group.prototype = {
*/
iterate: function (key, value, returnType, callback, callbackContext, args) {
if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length === 0)
if (returnType === Phaser.Group.RETURN_TOTAL && this._container.children.length === 0)
{
return -1;
}
@@ -1075,7 +1075,7 @@ Phaser.Group.prototype = {
callback.apply(callbackContext, args);
}
if (returnType == Phaser.Group.RETURN_CHILD)
if (returnType === Phaser.Group.RETURN_CHILD)
{
return currentNode;
}
@@ -1086,11 +1086,11 @@ Phaser.Group.prototype = {
while (currentNode != this._container.last._iNext);
}
if (returnType == Phaser.Group.RETURN_TOTAL)
if (returnType === Phaser.Group.RETURN_TOTAL)
{
return total;
}
else if (returnType == Phaser.Group.RETURN_CHILD)
else if (returnType === Phaser.Group.RETURN_CHILD)
{
return null;
}
@@ -1460,28 +1460,26 @@ Phaser.Group.prototype = {
/**
* @name Phaser.Group#total
* @property {number} total - The total number of children in this Group, regardless of their alive state.
* @property {number} total - The total number of children in this Group who have a state of exists = true.
* @readonly
*/
Object.defineProperty(Phaser.Group.prototype, "total", {
get: function () {
return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL);
// return this._container.children.length;
}
});
/**
* @name Phaser.Group#length
* @property {number} length - The number of children in this Group.
* @property {number} length - The total number of children in this Group, regardless of their exists/alive status.
* @readonly
*/
Object.defineProperty(Phaser.Group.prototype, "length", {
get: function () {
return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL);
// return this._container.children.length;
return this._container.children.length;
}
});
-11
View File
@@ -374,9 +374,6 @@ PIXI.DisplayObject.prototype.addFilter = function(data)
//this.filter = true;
// data[0].target = this;
console.log('addFilter');
console.log(data);
// insert a filter block..
// TODO Onject pool thease bad boys..
var start = new PIXI.FilterBlock();
@@ -395,8 +392,6 @@ console.log(data);
start.target = this;
console.log('start', start);
/*
* insert start
*/
@@ -484,13 +479,7 @@ PIXI.DisplayObject.prototype.removeFilter = function(data)
// console.log("YUOIO")
// modify the list..
console.log('DisplayObject removeFilter');
console.log(data);
var startBlock = data.start;
console.log('start', startBlock);
var nextObject = startBlock._iNext;
var previousObject = startBlock._iPrev;