I am trying to build 2D maps with Tiled Map Editor for my game, and I export them under text format, so a tile can look like this:



and so on, for many rows. In this link you can see an example of a map, to get a better idea.

Now let's say I have 3 layers, each using its own tileset. The numbers in the layer represent the ID of the tile, basically the number of the tile in the sheet. If grass is the 2nd tile, then the ID is 2, and so forth.

However, as you can see in the link, different tilesets will export different IDs per layer, notice how in the object layer I can have IDs such as 81, when in fact the ID is only 1, so it adds up 80 or so.

Since I am trying to make my map system as flexible as possible, I need the real ID in order to make some calculations. How does tiled export these sort of IDs? I simply want to determine what number to substract in order to get the id, like so:

tile.id = currentid - something_strange;


1 Answer 1


You are using Tiled map editor, but not using the TMX file format, right? I believe the something_strange comes from the first tile GID in the given tileset. Just save the tilemap as TMX and you should see something like:

 <tileset firstgid="49" name="nameoftileset" tilewidth="128" tileheight="128" spacing="2" margin="1">
  <image source="tiles.png" trans="ff00ff" width="520" height="260"/>

something_strange == firstgid

  • \$\begingroup\$ Also, what if I wanted to determine it from a simple text format? That firstgid doesn't appear in the regular text format \$\endgroup\$
    – Bugster
    Commented Jun 14, 2013 at 9:32
  • \$\begingroup\$ Because the tileset definitions are not there. You can calculate it simply by counting the tiles in the tileset. So if your background tileset is 128x128 and tile is 64x64, then the GIDs of background tileset will be {0, 1, 2, 3} and the next tileset {4, ...}. Or maybe it starts from 1, not 0. -- I don't like the text format, because it is not complete. I highly recommend using the TMX one, if you can. \$\endgroup\$ Commented Jun 14, 2013 at 9:35
  • \$\begingroup\$ The .txt format supported by Tiled is actually not a generic map format, but the map format used by the Flare game engine (which is also how this format is called in the Save dialog). See flarerpg.org for that particular game. \$\endgroup\$ Commented Jun 23, 2013 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .