i have a problem with resetting the position of the camera in a Java application. It's a side scroller game, where the camera is focused (zoomed) on a part of the screen..
in one class (UI) the camera has the following settings:
OrthographicCamera camera = new OrthographicCamera();
camera.setToOrtho(false, FlappyWizardGame.WIDTH / 2,FlappyWizardGame.HEIGHT / 2);
in the update() method the camera should follow the moving figure:
camera.position.x = wizard.getPosition().x + 80;
in the render() method:
spriteBatch.setProjectionMatrix(camera.combined);
now my problem is, when the player loses, another UI should pop up. But because of the camera's zoom, the Background (Texture) is not shown correctly..
I hope you understand what i mean and thanks for the help!
Kind regards!
EDIT: It appears that the problem is with the SpriteBatch, because it's set to "Camera.combined". Is there any way to reset it?
Offset the background Texture to draw at wizard.getPosition().x - offset. Where offset is the distance from the origin(top left) of wizard to the left side of the screen.
So the solution was to reposition the camera like this:
camera.setToOrtho(false, FlappyWizardGame.WIDTH, FlappyWizardGame.HEIGHT);
and in the render method to reset the SpriteBatch like this:
sb.setProjectionMatrix(camera.combined);
Thanks for your help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.