Skip to content

Commit e5ebfe8

Browse files
committed
Fix Tile.tileset to return just the containing tileset instead of all of them.
1 parent 43e76a7 commit e5ebfe8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/tilemaps/Tile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,9 @@ var Tile = new Class({
761761
},
762762

763763
/**
764-
* The tileset that contains this Tile. This will only return null if accessed from a LayerData
765-
* instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer.
764+
* The tileset that contains this Tile. This is null if accessed from a LayerData instance
765+
* before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has
766+
* an index that doesn't correspond to any of the map's tilesets.
766767
*
767768
* @name Phaser.Tilemaps.Tile#tileset
768769
* @type {?Phaser.Tilemaps.Tileset}
@@ -773,7 +774,12 @@ var Tile = new Class({
773774
get: function ()
774775
{
775776
var tilemapLayer = this.tilemapLayer;
776-
return tilemapLayer ? tilemapLayer.tileset : null;
777+
if (!tilemapLayer) return null;
778+
779+
var tileset = tilemapLayer.gidMap[this.index];
780+
if (!tileset) return null;
781+
782+
return tileset;
777783
}
778784
},
779785

0 commit comments

Comments
 (0)