2
votes

I have set up my Tiled Map likes so:

 level = new Level("level_1.tmx");
    renderer = new OrthogonalTiledMapRenderer(level.getMap(), UNIT_SCALE);
    spriteBatch = renderer.getBatch();
    debugRenderer = new ShapeRenderer();

    camera = new OrthographicCamera();
    camera.setToOrtho(false, 18, 10); //View is 18 by 10 tiles 
    camera.update();

However, since the number of tiles is hardcoded in, the screen will accordingly stretch with different screen sizes.

How do I customize the screen width so that it has the proper ratio and will properly scale to fill the screen with LibGDX and Android?

1

1 Answers

1
votes

If you want to see more tiled area on a screen, when its resolution more than origin, when you must set new camera viewport: camera.setToOrtho(false, Gdx.graphics.getWidth() / YOUR_TILE_PIXEL_WIDTH, Gdx.graphics.getHeight() / YOUR_TILE_PIXEL_HEIGHT) But if you always want to see the same amount of tiles on the screen, streched if screen resolution more than origin, then use StretchViewport

and take a look here