Skip to content

Commit e012115

Browse files
committed
DynamicTilemapLayer.destroy will now no longer run its destroy sequence again if it has already been run once. Fix phaserjs#4634
1 parent da49fcc commit e012115

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/tilemaps/dynamiclayer/DynamicTilemapLayer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ var DynamicTilemapLayer = new Class({
458458
{
459459
if (removeFromTilemap === undefined) { removeFromTilemap = true; }
460460

461+
if (!this.tilemap)
462+
{
463+
// Abort, we've already been destroyed
464+
return;
465+
}
466+
461467
// Uninstall this layer only if it is still installed on the LayerData object
462468
if (this.layer.tilemapLayer === this)
463469
{

src/tilemaps/staticlayer/StaticTilemapLayer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,13 @@ var StaticTilemapLayer = new Class({
14461446
{
14471447
if (removeFromTilemap === undefined) { removeFromTilemap = true; }
14481448

1449-
// Uninstall this layer only if it is still installed on the LayerData object
1449+
if (!this.tilemap)
1450+
{
1451+
// Abort, we've already been destroyed
1452+
return;
1453+
}
1454+
1455+
// Uninstall this layer only if it is still installed on the LayerData object
14501456
if (this.layer.tilemapLayer === this)
14511457
{
14521458
this.layer.tilemapLayer = undefined;

0 commit comments

Comments
 (0)