Curious how to go about the drawing of the ImageMapObjects? I’ve created my entire level-layout using them for placing my animated doors, ladders, chains, and even traps/obsticles, but it turns out that LibGDX doesn’t render it by default.
I’ve done some googling, but I can’t really figure out how to get them to draw.
Thanks in advance for any help.
SOLVED: Thanks to DermetFan
I think you mean TextureMapObjects. If you place an image on the tile map, the TmxMapLoader will not create a TextureMapObject from it.
It will be RectangleMapObject with a “gid” property instead.
You could override the OrthogonalTiledMapRenderer#renderObject(MapObject) method. It does nothing by default, but you can do this:
@Override
public void renderObject(MapObject object) {
if(object instanceof RectangleMapObject) {
RectangleMapObject rectObj = (RectangleMapObject) object;
if(rectObj.getProperties().containsKey("gid")) {
TiledMapTile tile = getMap().getTileSets().getTile(rectObj.getProperties().get("gid", Integer.class));
spriteBatch.draw(tile.getTextureRegion(), rectObj.getRectangle().x, rectObj.getRectangle().y);
}
}
}