Skip to content

Commit 3e6a88f

Browse files
committed
Group.remove now checks the child to see if it's a member of the root Group before removing it, otherwise Pixi throws an Error.
1 parent 82e23d8 commit 3e6a88f

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Version 2.0.4 - "Mos Shirare" - in development
6868
* Group.setProperty will now check if the property exists before setting it, this applies to Group.setAll and anything else using setProperty internally.
6969
* QuadTree.retrieve now checks to see if the given Sprite has a body before carrying on.
7070
* ArcadePhysics.collideSpriteVsGroup checks if Sprite has a body before carrying on, now safely skips sub-groups or other non-Sprite group children.
71-
71+
* Group.remove now checks the child to see if it's a member of the root Group before removing it, otherwise Pixi throws an Error.
7272

7373

7474
### New Features

src/core/Group.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,8 @@ Phaser.Group.prototype.getRandom = function (startIndex, length) {
14131413
};
14141414

14151415
/**
1416-
* Removes the given child from this Group and sets its group property to null.
1416+
* Removes the given child from this Group. This will dispatch an onRemovedFromGroup event from the child (if it has one),
1417+
* reset the Group cursor and optionally destroy the child.
14171418
*
14181419
* @method Phaser.Group#remove
14191420
* @param {Any} child - The child to remove.
@@ -1424,7 +1425,7 @@ Phaser.Group.prototype.remove = function (child, destroy) {
14241425

14251426
if (typeof destroy === 'undefined') { destroy = false; }
14261427

1427-
if (this.children.length === 0)
1428+
if (this.children.length === 0 || this.children.indexOf(child) === -1)
14281429
{
14291430
return false;
14301431
}

0 commit comments

Comments
 (0)