anza anza - 1 year ago 140
Java Question

LibGDX reset or remove Orthographic camera

I'm quite new to LibGDX but not a beginner in java programming. I was making a Flappy bird like game. I used Orthographic camera in my play state so it would follow the bird, but now i want to make a game over screen. I created a class with all the code i need but when i try it still uses the Orthographic camera at the birds position before it died, so the textures on that game over screen are heavily out of place, although isTouched() method is at the right position, so if i press that region i set earlier it restarts the game as it should. The only problem are the textures. Could someone help me solve the problem as i can't figure it out.

Answer Source

I think you want something similar to HUD, which is always displayed on the screen, right?

If so, you can use another orthographic camera, name it hudCam or something you remember. Not sure if necessary but I changed Y-down of the camera to false like this:

hudCamera.setToOrtho(false, WIDTH / 2, HEIGHT / 2); // width and height being the screen size

Then you can just switch between the cameras when drawing.

draw HUD stuff...

To get the correct mouse coordinates, just do like you did with the other camera, unproject it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download