Access texture of a single tile

Hey tile builders!

I just starting using Tiled and am looking for a way to programictically access a tiles texture. But all I found was its texture of the texture region which is the whole tileset (i.e. not the 32x32 texture but the whole 3250x3250 tileset). I’m currently using LIBGDX and seem to not find any method that returns a texture other than the whole tileset texture.

The places I’ve looked at so far is the cells and corresponding tiles as such:

(TiledMapTileLayer)tiledMap.getLayers().get("MyCustomLayer").getCell(0,0);
(TiledMapTileLayer)tiledMap.getLayers().get("MyCustomLayer").getCell(0,0).getTile();

Is there any way of getting the corresponding tile texture of one particular tile? I can see inside the .tmx that the map is saved in a base64 format, so maybe it is not accessable…

Okey I solved my own problem which was actually LIBGDX related…

Every TileMapTile object has a TextureRegion object which is what I was looking for. I did not know that TextureRegion objects can be handled that same as Texture objects.
To clearify for others if they fall into the same problem:

// returns the texture of that particular tile. dimensions are the same as the tile
(TiledMapTileLayer)tiledMap.getLayers().get("MyCustomLayer").getCell(0,0).getTile().getTextureRegion();

// returns the whole tileset that particular tile uses i.e. the tileset you use to draw the whole map
(TiledMapTileLayer)tiledMap.getLayers().get("MyCustomLayer").getCell(0,0).getTile().getTextureRegion().getTexture();
1 Like