3
\$\begingroup\$

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);
}
\$\endgroup\$
7
\$\begingroup\$

Is your tiled map isometric or it is orthographic ?

if it is orthographic use orthographic tiledmap renderer .


More specifically, change

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

to

renderer = new OrthogonalTiledMapRenderer(map, 1f/50f);
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.