mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
Fix removing destroyed Container child
This commit is contained in:
parent
47d393ac29
commit
5cd5cadf79
1 changed files with 21 additions and 2 deletions
|
@ -438,7 +438,7 @@ var Container = new Class({
|
||||||
*/
|
*/
|
||||||
addHandler: function (gameObject)
|
addHandler: function (gameObject)
|
||||||
{
|
{
|
||||||
gameObject.once(Events.DESTROY, this.remove, this);
|
gameObject.once(Events.DESTROY, this.onChildDestroyed, this);
|
||||||
|
|
||||||
if (this.exclusive)
|
if (this.exclusive)
|
||||||
{
|
{
|
||||||
|
@ -976,7 +976,7 @@ var Container = new Class({
|
||||||
{
|
{
|
||||||
if (list[i] && list[i].scene)
|
if (list[i] && list[i].scene)
|
||||||
{
|
{
|
||||||
list[i].off(Events.DESTROY, this.remove, this);
|
list[i].off(Events.DESTROY, this.onChildDestroyed, this);
|
||||||
|
|
||||||
list[i].destroy();
|
list[i].destroy();
|
||||||
}
|
}
|
||||||
|
@ -1452,6 +1452,25 @@ var Container = new Class({
|
||||||
this.tempTransformMatrix.destroy();
|
this.tempTransformMatrix.destroy();
|
||||||
|
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal handler, called when a child is destroyed.
|
||||||
|
*
|
||||||
|
* @method Phaser.GameObjects.Container#onChildDestroyed
|
||||||
|
* @protected
|
||||||
|
* @since 3.70.1
|
||||||
|
*/
|
||||||
|
onChildDestroyed: function (gameObject)
|
||||||
|
{
|
||||||
|
ArrayUtils.Remove(this.list, gameObject);
|
||||||
|
|
||||||
|
if (this.exclusive)
|
||||||
|
{
|
||||||
|
gameObject.parentContainer = null;
|
||||||
|
|
||||||
|
gameObject.removedFromScene();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue