Skip to content
Casey Baxter edited this page Sep 7, 2012 · 10 revisions

The gid (global id) of a Tile is what makes it unique among other tiles. If you know a tile's gid you can retrieve it from a map using the table Map.tiles.

An example:

-- This draws tile number 5 at location (50,50).  
map.tiles[5]:draw(50,50)

A tile's gid is determined by what position it is inside of a TileSet's image plus the value of tileset's firstgid. The tile at the top-left corner of the image has a value of 0 and each tile going from left-to-right, top-to-bottom will increment this value. If the map only contains one tileset then its firstgid will always be 1. Subsequent tilesets will have a firstgid equal to the gid of last tile in the previous tileset +1.

If we have two tilesets then the second one's firstgid will be one more than the last tile's gid in the previous tileset. Like so: [gidexample.png]


###See Also Tile
TileSet
Home

Clone this wiki locally