Layers and Tiles Confusion

I created a single layer, added tiles using a spritesheet that I created and exported it for use with Cocos2D.

The tiled map looks fine in Cocos2D, but I’m a little confused on how to determine which tile is which. I thought I could by using the local ID, but when I open up the tmx file in a text editor the numbers don’t match. I’m assuming it’s a GID which is fine, but I’m confused as to how I can know the identity of each tile within my game?

For example I made a background with TiledMap and for two specific tiles I would like to place another image over it dynamically.


help you here?

Basically you need to subtract the tileset gid from the id you read from the file (and deal with the bit masking used for rotating/flipping).


In such cases it is usually preferable to set a custom property on the tiles, identifying which other image should be placed over it dynamically. That way you avoid hardcoding tile indexes in your game. Just a suggestion.