I've followed the advice in this post to handle world/screen coordinates, but I'm getting results I don't quite understand, as I'm not terribly good in math.
So, when I use this code:
SpriteBatch batch;
OrthographicCamera camera;
public static float width = 0, height = 0;
private void setupGraphics(SpriteBatch batch) {
height = Constants.TILES_Y; // 20
float pixelsPerUnit = Gdx.graphics.getHeight() / height;
width = Gdx.graphics.getWidth() / pixelsPerUnit;
Gdx.app.log("debug", "Width: " + width + " height: " + height + " ppu: " + pixelsPerUnit);
camera = new OrthographicCamera(width, height);
camera.position.set(0, 0 / 2, 0);
camera.update();
batch.setProjectionMatrix(camera.combined);
}
...the result looks like this - it seems that the view height is now 20 pixels, not 20 32x32 tiles:
However, when I add a multiplier to the height, like 16, the result looks like this, which is more like what I want:
Here's the changed code:
height = Constants.TILES_Y * Constants.TILES_MULTIPLIER; // 20 * 16
How would I modify the code to avoid having to supply the multiplier every time when I handle coordinates?