user1001506
user1001506

Reputation:

Libgdx How to focus camera only on part of the actual screen?

So am working with making my game work on all resolutions, and I have made it that 16:9 aspect ratio is turned to 5:3 as my game logic is made in 5:3 dimensions but when the screen is 16:9 I have to cut off some of the top. In simple terms I have a 1280x768 screen trying to fit into a 1280x720 space. All it does now is squeeze the image height to fit into the 720 piece.

What I do now is set the camera to 1280x768 then tried to use a viewport set to 1280x720 but no change was seen. Basically how do I effectively cut some part of the screen off?

Upvotes: 1

Views: 534

Answers (1)

aug13
aug13

Reputation: 369

Most of the time we set the position of the camera as the center of the screen,but you can alter it with camera.position.set(x,y,z).If you wish to cut some portion,then just set the position of the camera accordingly.In addition to this,You can use the functions like camera.translate(x,y,z) through which you can translate the position of your camera. You can also use the camera.zoom to add some zooming effect into it. Don't forget to add camera.update() after doing any of the operations on your camera.

Upvotes: 2

Related Questions