简体   繁体   中英

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

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)

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 .

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM