MapData.getTileset

Fetch the tileset containing the tile a given GID. Throws if the gid is out of range for all tilesets

  1. auto getTileset(string name)
  2. auto getTileset(TiledGid gid)
    struct MapData
    getTileset

Parameters

gid
Type: TiledGid

gid of tile to find tileset for

Return Value

Type: auto

Tileset containing the given gid

Examples

1 MapData map;
2 map.tilesets ~= TilesetData();
3 map.tilesets[0].firstGid = 1;
4 map.tilesets ~= TilesetData();
5 map.tilesets[1].firstGid = 5;
6 map.tilesets ~= TilesetData();
7 map.tilesets[2].firstGid = 12;
8 
9 assert(map.getTileset(1) == map.tilesets[0]);
10 assert(map.getTileset(3) == map.tilesets[0]);
11 assert(map.getTileset(5) == map.tilesets[1]);
12 assert(map.getTileset(9) == map.tilesets[1]);
13 assert(map.getTileset(15) == map.tilesets[2]);

Meta