Problem when scaling game screen in Libgdx
- by Nicolas Martel
Currently, I'm able to scale the screen by applying this bit of code onto an OrthographicCamera
Camera.setToOrtho(true, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
But something quite strange is happening with this solution, take a look at this picture of my game below
Seems fine right? But upon further investigation, many components are rendered off by one pixels, and the tiles all are.
Take a closer look
I circled a couple of the errors. Note that the shadow of the warrior I circled appears fine for the other warriors. Also keep in mind that everything is rendered at pixel-perfect precision when I disable the scaling.
I actually thought of a possible source for the problem as I'm writing this but I decided to still post this because I would assume somebody else might run into the same issue.