mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
Groups will now listen for a destroy
event from any Game Object added to them, and if received will automatically remove that GameObject from the Group. Fix #3418
This commit is contained in:
parent
cb5b12e9d3
commit
b6f2c80ae6
2 changed files with 12 additions and 5 deletions
|
@ -29,6 +29,7 @@ A special mention must go to @orblazer for their outstanding assistance in helpi
|
|||
* Camera.flash now has an optional `callback` argument that is invoked when the effect completes (thanks @pixelscripter)
|
||||
* Camera.fadeIn is a new method that will fade the camera in from a given color (black by default) and then optionally invoke a callback. This is the same as using Camera.flash but with an easier to grok method name. Fix #3412 (thanks @Jerenaux)
|
||||
* Camera.fadeOut is a new method that will fade the camera out to a given color (black by default) and then optionally invoke a callback. This is the same as using Camera.fade but with an easier to grok method name. Fix #3412 (thanks @Jerenaux)
|
||||
* Groups will now listen for a `destroy` event from any Game Object added to them, and if received will automatically remove that GameObject from the Group. Fix #3418 (thanks @hadikcz)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -406,6 +406,8 @@ var Group = new Class({
|
|||
}
|
||||
}
|
||||
|
||||
child.on('destroy', this.remove, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -462,6 +464,8 @@ var Group = new Class({
|
|||
}
|
||||
}
|
||||
|
||||
child.off('destroy', this.remove, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -479,14 +483,16 @@ var Group = new Class({
|
|||
{
|
||||
if (removeFromScene === undefined) { removeFromScene = false; }
|
||||
|
||||
if (removeFromScene)
|
||||
{
|
||||
var children = this.children;
|
||||
|
||||
for (var i = 0; i < children.size; i++)
|
||||
{
|
||||
var gameObject = children.entries[i];
|
||||
|
||||
gameObject.off('destroy', this.remove, this);
|
||||
|
||||
if (removeFromScene)
|
||||
{
|
||||
this.scene.sys.displayList.remove(gameObject);
|
||||
|
||||
if (gameObject.preUpdate)
|
||||
|
|
Loading…
Reference in a new issue