Skip to content

Commit

Permalink
Merge pull request #4152 from quadrupleslap-forks-things/master
Browse files Browse the repository at this point in the history
Fix Tile.tileset to return just the containing tileset instead of all…
  • Loading branch information
photonstorm authored Nov 20, 2018
2 parents 8289e66 + e5ebfe8 commit 4534222
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/tilemaps/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,9 @@ var Tile = new Class({
},

/**
* The tileset that contains this Tile. This will only return null if accessed from a LayerData
* instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer.
* The tileset that contains this Tile. This is null if accessed from a LayerData instance
* before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has
* an index that doesn't correspond to any of the map's tilesets.
*
* @name Phaser.Tilemaps.Tile#tileset
* @type {?Phaser.Tilemaps.Tileset}
Expand All @@ -773,7 +774,12 @@ var Tile = new Class({
get: function ()
{
var tilemapLayer = this.tilemapLayer;
return tilemapLayer ? tilemapLayer.tileset : null;
if (!tilemapLayer) return null;

var tileset = tilemapLayer.gidMap[this.index];
if (!tileset) return null;

return tileset;
}
},

Expand Down

0 comments on commit 4534222

Please sign in to comment.