diff --git a/src/tilemaps/mapdata/LayerData.js b/src/tilemaps/mapdata/LayerData.js index 26087254c..92c0294e9 100644 --- a/src/tilemaps/mapdata/LayerData.js +++ b/src/tilemaps/mapdata/LayerData.js @@ -38,6 +38,17 @@ var LayerData = new Class({ */ this.name = GetFastValue(config, 'name', 'layer'); + /** + * The id of the layer, as specified in the map data. + * + * Note: This is not the index of the layer in the map data, but its actual ID in Tiled. + * + * @name Phaser.Tilemaps.LayerData#id + * @type {number} + * @since 3.60.1 + */ + this.id = GetFastValue(config, 'id', 0); + /** * The x offset of where to draw from the top left. * diff --git a/src/tilemaps/mapdata/ObjectLayer.js b/src/tilemaps/mapdata/ObjectLayer.js index 5183db546..3f1264652 100644 --- a/src/tilemaps/mapdata/ObjectLayer.js +++ b/src/tilemaps/mapdata/ObjectLayer.js @@ -40,6 +40,15 @@ var ObjectLayer = new Class({ */ this.name = GetFastValue(config, 'name', 'object layer'); + /** + * The id of the object layer, as specified in the map data. + * + * @name Phaser.Tilemaps.ObjectLayer#id + * @type {number} + * @since 3.60.1 + */ + this.id = GetFastValue(config, 'id', 0); + /** * The opacity of the layer, between 0 and 1. * diff --git a/src/tilemaps/parsers/tiled/ParseTileLayers.js b/src/tilemaps/parsers/tiled/ParseTileLayers.js index 31c268ac4..05a99f6b9 100644 --- a/src/tilemaps/parsers/tiled/ParseTileLayers.js +++ b/src/tilemaps/parsers/tiled/ParseTileLayers.js @@ -122,6 +122,7 @@ var ParseTileLayers = function (json, insertNull) layerData = new LayerData({ name: (curGroupState.name + curl.name), + id: curl.id, x: (curGroupState.x + GetFastValue(curl, 'offsetx', 0) + layerOffsetX * json.tilewidth), y: (curGroupState.y + GetFastValue(curl, 'offsety', 0) + layerOffsetY * json.tileheight), width: curl.width, @@ -202,6 +203,7 @@ var ParseTileLayers = function (json, insertNull) { layerData = new LayerData({ name: (curGroupState.name + curl.name), + id: curl.id, x: (curGroupState.x + GetFastValue(curl, 'offsetx', 0) + curl.x), y: (curGroupState.y + GetFastValue(curl, 'offsety', 0) + curl.y), width: curl.width,