From 13b6d6d5ae2eeac2845073b70c78d1ce41a27472 Mon Sep 17 00:00:00 2001 From: Seth Berrier Date: Thu, 31 Oct 2019 16:03:48 -0500 Subject: [PATCH] Fix for bug related to Issue #4737 - When removing a layer from a tilemap, layerIndex can become invalid - Added loop to fix any existing tilemapLayer.layerIndex vales --- src/tilemaps/Tilemap.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index 54bba4b10..2867fcff6 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -1564,6 +1564,13 @@ var Tilemap = new Class({ if (index !== null) { SpliceOne(this.layers, index); + for (var i = index; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.layerIndex--; + } + } if (this.currentLayerIndex === index) {