Merge pull request #6542 from rui-han-crh/expose-layer-id

Expose layer id from Tiled map parser in LayerData and ObjectLayer
This commit is contained in:
Richard Davey 2023-07-21 16:40:53 +01:00 committed by GitHub
commit 80515012bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -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.
*

View file

@ -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.
*

View file

@ -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,