mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Fixed the use of the destroy parameter in Group.removeAll and related functions (thanks @AnderbergE, fix #717)
This commit is contained in:
parent
2fd704062d
commit
f70e4d7d90
2 changed files with 12 additions and 27 deletions
|
@ -72,6 +72,8 @@ Version 2.0.4 - "Mos Shirare" - in development
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* The main Timer loop could incorrectly remove TimeEvent if a new one was added specifically during an event callback (thanks @garyyeap, fix #710)
|
* The main Timer loop could incorrectly remove TimeEvent if a new one was added specifically during an event callback (thanks @garyyeap, fix #710)
|
||||||
|
* Fixed the use of the destroy parameter in Group.removeAll and related functions (thanks @AnderbergE, fix #717)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
There is an extensive [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) available for those converting from Phaser 1.x to 2.x. In the guide we detail the API breaking changes and approach to our new physics system.
|
There is an extensive [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) available for those converting from Phaser 1.x to 2.x. In the guide we detail the API breaking changes and approach to our new physics system.
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ Phaser.Group.prototype.remove = function (child, destroy) {
|
||||||
child.events.onRemovedFromGroup.dispatch(child, this);
|
child.events.onRemovedFromGroup.dispatch(child, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeChild(child);
|
var removed = this.removeChild(child);
|
||||||
|
|
||||||
this.updateZ();
|
this.updateZ();
|
||||||
|
|
||||||
|
@ -1420,9 +1420,9 @@ Phaser.Group.prototype.remove = function (child, destroy) {
|
||||||
this.next();
|
this.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroy)
|
if (destroy && removed)
|
||||||
{
|
{
|
||||||
child.destroy();
|
removed.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1452,11 +1452,11 @@ Phaser.Group.prototype.removeAll = function (destroy) {
|
||||||
this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
|
this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeChild(this.children[0]);
|
var removed = this.removeChild(this.children[0]);
|
||||||
|
|
||||||
if (destroy)
|
if (destroy && removed)
|
||||||
{
|
{
|
||||||
this.children[0].destroy();
|
removed.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (this.children.length > 0);
|
while (this.children.length > 0);
|
||||||
|
@ -1497,11 +1497,11 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy)
|
||||||
this.children[i].events.onRemovedFromGroup.dispatch(this.children[i], this);
|
this.children[i].events.onRemovedFromGroup.dispatch(this.children[i], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeChild(this.children[i]);
|
var removed = this.removeChild(this.children[i]);
|
||||||
|
|
||||||
if (destroy)
|
if (destroy && removed)
|
||||||
{
|
{
|
||||||
this.children[i].destroy();
|
removed.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cursor === this.children[i])
|
if (this.cursor === this.children[i])
|
||||||
|
@ -1530,24 +1530,7 @@ Phaser.Group.prototype.destroy = function (destroyChildren, soft) {
|
||||||
if (typeof destroyChildren === 'undefined') { destroyChildren = true; }
|
if (typeof destroyChildren === 'undefined') { destroyChildren = true; }
|
||||||
if (typeof soft === 'undefined') { soft = false; }
|
if (typeof soft === 'undefined') { soft = false; }
|
||||||
|
|
||||||
if (destroyChildren)
|
this.removeAll(destroyChildren);
|
||||||
{
|
|
||||||
if (this.children.length > 0)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (this.children[0].parent)
|
|
||||||
{
|
|
||||||
this.children[0].destroy(destroyChildren);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (this.children.length > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.removeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cursor = null;
|
this.cursor = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue