Tile ID is not static

Hi,
I have a similar question to the one asked here but the answers given still do not help me.

I’m using Qiso plugin with the Corona SDK and I add my tiles to the map by calling the TileID (via Qiso). I have a database when I store my Tile IDs, eg:
ID, BuildingID, TileID, X, Y…
Right now I’m using the firstgid (stated in the lua file) + the ID given in the tile property (see snapshot)
image
but from what I uderstand this is not the way to go. I am facing a problem where the firstgid changes when I re-order my tilesets.

So what is the way to go and what do you mean by “mapping this global tile ID to a tileset” ?
Thanks a lot!

Yes, the “firstgid” generally only exists in the map file and not in memory. It is only used to assign global IDs to all tiles so that tile layers and objects can refer to the tiles by simple numbers rather than tileset + local id pairs.

So in your game you should generally not use the global ID to associate other information with the tile or to refer to a specific tile. Instead, use the local ID (highlighted in your screenshot) and the tileset if needed to refer a specific tile.

Sometimes you can also use custom properties to set up this data. For example, if your building tiles have a custom property “BuildingID”, then this provides a quick way to know the building given a tile, and upon loading a tileset you can easily set up a reverse mapping from BuildingID to tile if needed.

Ok, I understand now.
I will need to do something like addToTile(x, y, tilesetName, localID) with Qiso but there is no way to get the tileset informartion with Qiso, as far as I can see.
It seems there is no way to retrieve custom properties with Qiso either.

I will see if the Qiso team has a suggestion or could implement that. Thanks!

I had issues with this in the past, so I opted to identify my tiles by source image name. Of course this only works with separate tile images (not a whole tilesheet). But I prefer the workflow because I know I am always referring to the exact tile image that I want regardless of how they are arranged in the tileset.

I got some help from the Qiso team. For details see this post

1 Like

Hey @Javo, thanks for sharing that!

Regarding the solution suggested at the end, I’d avoid maintaining a list with “firstgid” values manually, since the list can be different for each map and would be annoying to maintain even when you managed to use the same tileset order for each map. If you instead use the names of the tilesets, then you can look up the firstgids of those tilesets dynamically after loading each map.