Skip to content

Game Camera

miguel edited this page May 13, 2019 · 3 revisions

We can display game objects on the screen but we can not move in the world without having a camera. libgdx already implements an OrthographicCamera class which is used by braingdx in order to add additional functionality:

GameCamera camera = context.getGameCamera();
// Camera now tracks the game object
camera.setTrackingTarget(object);
// Speed how fast the camera should track the game object
camera.setTargetTrackingSpeed(2f);
// Determines how the camera should apply zoom when tracking
camera.setZoomScalingFactor(2.5f);
// Focus the camera into the middle of the game object/screen (default)
camera.focusCentered();
// Retrieve the libgdx camera
Camera libgdxCamera = camera.getInternalCamera();
Clone this wiki locally