mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 17:28:18 +00:00
Merge pull request #6039 from rexrainbow/layer-destroy
Destroy game objects safely in layer.destroy()
This commit is contained in:
commit
cceb70a937
1 changed files with 6 additions and 4 deletions
|
@ -933,8 +933,10 @@ var Layer = new Class({
|
|||
* @method Phaser.GameObjects.Layer#destroy
|
||||
* @fires Phaser.GameObjects.Events#DESTROY
|
||||
* @since 3.50.0
|
||||
*
|
||||
* @param {boolean} [fromScene=false] - `True` if this Game Object is being destroyed by the Scene, `false` if not.
|
||||
*/
|
||||
destroy: function ()
|
||||
destroy: function (fromScene)
|
||||
{
|
||||
// This Game Object has already been destroyed
|
||||
if (!this.scene || this.ignoreDestroy)
|
||||
|
@ -944,11 +946,11 @@ var Layer = new Class({
|
|||
|
||||
this.emit(GameObjectEvents.DESTROY, this);
|
||||
|
||||
var i = this.list.length;
|
||||
var list = this.list;
|
||||
|
||||
while (i--)
|
||||
while (list.length)
|
||||
{
|
||||
this.list[i].destroy();
|
||||
list[0].destroy(fromScene);
|
||||
}
|
||||
|
||||
this.removeAllListeners();
|
||||
|
|
Loading…
Reference in a new issue