How do I determine the width and height of my orthographic camera depending on my platform?
Asked Answered
A

2

0

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)

Abiotic answered 12/10, 2013 at 4:45 Comment(1)
I suggest you try out some things. It is really easy to understand once you see how it works in a few examples.Josphinejoss
K
2

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.

Khaki answered 12/10, 2013 at 8:36 Comment(0)
S
0

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.

Salinometer answered 12/10, 2013 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.