LibGDX IsometricTiledMapRenderer issues

283 views Asked by At

I'm having an issue where my isometric map is rotated 90 degrees anti clockwise when rendering with the IsometricTiledMapRenderer.

Image of the issue. https://i.stack.imgur.com/LukJE.jpg

public class Heist extends ApplicationAdapter {
    public static final String MAP_NAME = "map.tmx";

  OrthographicCamera camera;
  IsometricTiledMapRenderer mapRenderer;
  TiledMap map;
    SpriteBatch batch;

    @Override
    public void create () {
        batch = new SpriteBatch();
        camera = new OrthographicCamera();
        camera.setToOrtho(true, 30, 20);

        map = new TmxMapLoader().load(MAP_NAME);

        mapRenderer = new IsometricTiledMapRenderer(map, 1/32f);
        mapRenderer.setView(camera);
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.begin();
    mapRenderer.render();
        batch.end();
    }
}
1

There are 1 answers

0
yasith On

Turns out it's because of this line.

camera.setToOrtho(true, 30, 20);

The y axis is inverted in this case. We want it to be.

camera.setToOrtho(false, 30, 20);