Why is my Tiled map distorted when rendered with LibGDX?

Posted by Sean on Game Development See other posts from Game Development or by Sean
Published on 2013-11-04T03:04:22Z Indexed on 2013/11/04 4:15 UTC
Read the original article Hit count: 542

Filed under:
|
|

I have a Tiled map that looks like this in the editor:

enter image description here

But when I load it using an AssetManager (full static source available on GitHub) it appears completely askew.

enter image description here

I believe the relevant portion of the code is below. This is the entire method; the others are either empty or might as well be.

private OrthographicCamera camera;
private AssetManager assetManager;
private BitmapFont font;
private SpriteBatch batch;
private TiledMap map;
private TiledMapRenderer renderer;

@Override
public void create() {      
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera();
    assetManager = new AssetManager();
    batch = new SpriteBatch();
    font = new BitmapFont();

    camera.setToOrtho(false, (w / h) * 10, 10);
    camera.update();

    assetManager.setLoader(TiledMap.class,
            new TmxMapLoader(
                    new InternalFileHandleResolver()));
    assetManager.load(AssetInfo.ICE_CAVE.assetPath, TiledMap.class);
    assetManager.finishLoading();

    map = assetManager.get(AssetInfo.ICE_CAVE.assetPath);

    renderer = new IsometricTiledMapRenderer(map, 1f/64f);
}

© Game Development or respective owner

Related posts about rendering

Related posts about libgdx