# Using latest TiledMap, how do you get a specific tile from x and y index?

Seems basic enough, but I can't seem to find the answer: I am trying to implement collission detecton and for that I need the properties of the tile the player is currently entering. I am using gdx.maps.tiles.TiledMap, which does not have a getCell(int x, int y) like the older TileMap had. Any help on this specific issue or just some general advice on how to do this will be much appreciated!

With the new libGDX tiled maps implementation, you need to request the concerned layer before being able to request for a particular tile.

So:

TiledMapTileLayer layer = (TiledMapTileLayer) currentMap.getLayers().get("layer_id");


And then i can do:

layer.getCell(x, y);


Which will return a Cell instance.

Here is the new documentation about tile maps: https://github.com/libgdx/libgdx/wiki/Tile-maps

• Thank you very much! I did already use layers, but I didn't use the cast, which was the problem. – Ghyl Dec 27 '13 at 13:46