Question

I'm currently studying how to use libgdx and now I'm wrestling with the idea of an orthographic camera. I've watched a video explaining the difference between a perspective camera and an orthographic camera, and now I think I'm ready to get to the code.

How do I find out what dimensions (height, width) I should set for the viewport of my orthographic camera?

Does it depend on my platform? (mobile, desktop, etc)

Does a viewport need to be a certain shape? (square or rectangle)

Was it helpful?

Solution

You can always use this for every device what ever its width,height is:

OrthographicCamera camera;

int screenWidth = Gdx.graphics.getWidth();
int screenHeight = Gdx.graphics.getHeight();

camera = new OrthographicCamera(screenWidth, screenHeight);
camera.position.set(screenWidth * 0.5f, screenHeight * 0.5f, 0);

Although its useful when your using a orthographic camera, This code can be used anywhere even if you'r not using a orthographic camera.

OTHER TIPS

i think you should use 480x800(width,height) for portrait mode games and 800x480(width,height) for landscape mode gamess.

no it does not depend on platform, but graphics quality may varyyy for eg. if u are using low quality images(textures) in your game than they will look bad in bigger devies,so in my opinion you should use images/graphics which should look good in all devies, small as well as bigger devices..

view port should be rectangular.

because its the viewing region in computer graphics,and all the phones are rectangular in shapeee.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top