How can I render Images from an Object Layer?

So I am new and I was following a tutorial I saw in youtube. I wanted to draw some images with hitbox, but I wanted to rotate and manipulate those images, so I added them in an Object Layer. Plus I added some Rectangles to set their hitbox.
I code with Libgdx and when I try to render the map, it only renders the tile layer. so the Images are not rendered, any idea on how to get those images rendered?
Thank you all!
I have been searching this for a while and I have not found any answer to this. Sorry for my bad english or my bad knowledge!

If libgdx does not implement rendering of tile objects, then you’d need to render them yourself. However, I can’t imagine you’re the first one with this need, so maybe it would help to ask in the libgdx community about this.

Yeah, I was unaware of this. What I did is:

public class OrthogonalTiledMapRendererWithSprites extends OrthogonalTiledMapRenderer {

public OrthogonalTiledMapRendererWithSprites(TiledMap map) {
    super(map);
}
@Override
public void renderObject(MapObject object) {
    if(object instanceof TextureMapObject) {
        TextureMapObject textureObj = (TextureMapObject) object;
        batch.draw(textureObj.getTextureRegion(), textureObj.getX(), textureObj.getY(),
                textureObj.getOriginX(), textureObj.getOriginY(), textureObj.getTextureRegion().getRegionWidth(), textureObj.getTextureRegion().getRegionHeight(),
                textureObj.getScaleX(), textureObj.getScaleY(), textureObj.getRotation());
       if(textureObj.getProperties().containsKey("this")) System.out.println(textureObj.getRotation());
    } else if(object instanceof RectangleMapObject){
        RectangleMapObject rectObject = (RectangleMapObject) object;
        Rectangle rect = rectObject.getRectangle();
        ShapeRenderer sr = new ShapeRenderer();
        sr.setProjectionMatrix(batch.getProjectionMatrix());
        sr.begin(ShapeRenderer.ShapeType.Line);
        sr.rect(rect.x, rect.y, rect.width, rect.height);
        sr.end();
    }
}

}

Because that method was empty. Thank you for the answer!

1 Like