I am making a game where player sees the game from top. (GTA2 type of viewing) Thus camera follows the player as he moves anywhere in the map. However as the camera position changes, the images shake very slightly.
I have already checked the x and y variables of the shaking objects and even when they are constant, isolated from the other components of the game, I have the same issue. But it is gone when I test the game in fullscreen, so probably libgdx somehow rounds the objects position when the camera dimensions are small. Another clue is that when I use images with very thin lines (like image of a net), only some of the lines appear depending on camera position (it is again solved when I use fullscreen). So the solution is probably something like
font.setUseIntegerPositions(false);
in terms of SpriteBatch.
The camera dimensions and initialization is as follows:
public static int cameraWidth = 620;
public static int cameraHeight = 320;
...
camera = new OrthographicCamera();
camera.setToOrtho(false, cameraWidth, cameraHeight);
//---inside the render--
//Update the Time Variable
stateTime += Gdx.graphics.getDeltaTime();
//Clear the Screen
Gdx.gl.glClearColor(1F, 1F, 1F, 1F);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
//Set the Camera
final float cameraMaxY = mapHeight+menuHeight-cameraHeight/2;
final float cameraMinY = cameraHeight/2;
final float cameraMovableY = cameraMaxY - cameraMinY;
final float cameraMaxX = mapWidth-cameraWidth/2;
final float cameraMinX = cameraWidth/2;
final float cameraMovableX = cameraMaxX - cameraMinX;
camera.position.set(cameraMinX+cameraMovableX*cameraFollow.body.getPosition().x/mapWidth,cameraMinY+cameraMovableY*cameraFollow.body.getPosition().y/mapHeight,0);
camera.update();
where cameraFollow is just a variable that represents an object in physics world. I am sure camera.position.set algorithm is not the cause. What can I do to make libgdx draw everything in their exact positions without any approximations?