camera property

CameraComponent get camera

The component that is responsible for rendering your world.

In this component you can set different viewports, viewfinders, follow components, set bounds for where the camera can move etc.

You don't have to add the CameraComponent to the tree after setting it here, it is done automatically.

When setting the camera, if it doesn't already have a world it will be set to match the game's world.

Implementation

CameraComponent get camera => _camera;
set camera (CameraComponent newCameraComponent)

Implementation

set camera(CameraComponent newCameraComponent) {
  _camera.removeFromParent();
  _camera = newCameraComponent;
  if (_camera.parent == null) {
    add(_camera);
  }
  _camera.world ??= world;
}