# Layers and Tiles Confusion

**URL:** <https://discourse.mapeditor.org/t/layers-and-tiles-confusion/1968>\
**Category:** Questions\
**Created:** [January 17, 2017, 9:49pm UTC](https://discourse.mapeditor.org/t/layers-and-tiles-confusion/1968 "2017-01-17T21:49:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marquisk2](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Marquisk2](https://discourse.mapeditor.org/u/Marquisk2)\
**Post date:** [January 17, 2017, 9:49pm UTC](https://discourse.mapeditor.org/t/layers-and-tiles-confusion/1968/1 "2017-01-17T21:49:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ablu](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ablu/32/1496_2.png) [@Ablu](https://discourse.mapeditor.org/u/Ablu)\
**Post date:** [February 18, 2017, 5:03pm UTC](https://discourse.mapeditor.org/t/layers-and-tiles-confusion/1968/2 "2017-02-18T17:03:09Z")

</div>

Does

[http://doc.mapeditor.org/reference/tmx-map-format/#data](http://doc.mapeditor.org/reference/tmx-map-format/#data)

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).

Regards,  
Ablu

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [February 20, 2017, 1:31pm UTC](https://discourse.mapeditor.org/t/layers-and-tiles-confusion/1968/3 "2017-02-20T13:31:49Z")

</div>

> [@Marquisk2](#):
>
> For example I made a background with TiledMap and for two specific tiles I would like to place another image over it dynamically.

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.
