简体   繁体   中英

LibGDX/Android development: Managing cameras across multiple screens

I have an android application consisting of 4 different screens. I am currently creating a new camera for each screen. Each of these screens have the same height and width. Is there a better way to handle this camera, rather than creating a new one for each screen, or is that necessary?

You could make a class like GameObjects and declare there your public static camera.

public static Camera camera;

Now in every screen you got, in the show method you would probably need to reset what you changed to it. Example, if your camera was moving in a screen, you might want to set the position of the camera again in the show method (same thing about zoom, rotation etc). You call your camera functions with GameObjects.camera, ex: GameObjects.camera.update();

I create a camera and spritebatch for every screen I have, and it's ok! Don't worry too much about it. I don't really think that making just one camera is a good ideea anyways.

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