I am using LibGDX to learn Game Development. I have reached the phase I am learning to use Tiled Maps.

In Tiled map editor, there is a feature where we can pick a tile in the tile set, go to View -> Tile Collision Editor, and add shape objects to a tile.

I can see that the shapes are saved in the tmx file and associated to the tile.

For testing purpose, I have also made the tile animated (similar option is available under view menu) and the OrthogonalTiledMapRendered automatically animated it (so this information is being accessed somehow).

I wanted to find out if there is anyway to retrieve other information embedded at tile level like the embedded shapes and objects.

Here is the sample xml from the tmx file.

<tile id="7">
        <property name="customProp1" value="customValue1"/>
    <image width="16" height="16" source="black_hole_swallow_4.png"/>
    <objectgroup draworder="index">
        <object id="0" x="0.25" y="0">
            <polyline points="0,0 15.625,-0.25"/>
        <frame tileid="5" duration="300"/>
        <frame tileid="7" duration="200"/>

2 Answers 2


There are documents in libGDX's github wiki https://github.com/libgdx/libgdx/wiki/Tile-maps According to this page, you can get your objects by finding the layer contains them.

MapLayer layer = map.getLayers().get("my-layer");

Find your objects

MapObjects objects = layer.getObjects();

And get the object


There are many information you can get from the object

String name = object.getName();
float opacity = object.getOpacity();
boolean isVisible = object.isVisible();
Color color = object.getColor();

For more details you can go to the link above.

There are many more functions, like checking if the object is RectangleMapObject or PolygonMapObject etc.

  • \$\begingroup\$ Why is this answer accepted? This does not work. Embedded collision objects inside tile layers can't be fetched, because LibGDX simply does not set the MapObjects from tilelayers. You can only achieve this by overriding BaseTmxMapLoader#loadTileLayer() and make sure the MapObjects also get stored. Or add a manual collision object layer inside Tiled. \$\endgroup\$
    – TJRC
    Dec 15, 2019 at 21:44

LibGDX doesn't support <objectgroup> inside <tile>, yet. However, it could come, soon.

Please see Add handling of in in the com.badlogic.gdx.maps.tiled package #3751 and Tiled map tiles objects support #4542 for details.

  • \$\begingroup\$ If the details are relevant to the answer, please include them, here. \$\endgroup\$
    – Gnemlock
    Jul 21, 2017 at 7:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .