Im using libGdx to develop a 2d game, which has the following:
-
The world moves in an upward direction by having a camera follow the player’s y position.
-
The user only controls player’s x movement, the y is a constant speed.
What i want to do now is let the user control the players x and y movement and let the camera move constantly up without following the player.
What is the best way to do this?
This is what i tried:
in Render()
player.body.setTransform(fingerPosition.x, fingerPosition.y, player.body.getAngle());
box2dCamera.position.y = box2dCamera.position.y + cameraSpeed;
box2dCamera.update();
box2dSpriteBatch.setProjectionMatrix(box2dCamera.combined);
This worked but all my collisions stopped working with other box2d bodies. Do i need to update each body in my game with the recalculated camera some-how? How would I do this?