followComponent method

  1. @override
void followComponent(
  1. PositionComponent component, {
  2. Anchor relativeOffset = Anchor.center,
  3. Rect? worldBounds,
})

Immediately snaps the camera to start following the component.

This means that the camera will move so that the position vector of the component is in a fixed position on the screen. That position is determined by a fraction of screen size defined by relativeOffset (default to the center). worldBounds can be optionally set to add boundaries to how far the camera is allowed to move. The component is "grabbed" by its anchor (default top left). So for example if you want the center of the object to be at the fixed position, set the components anchor to center.

Implementation

@override
void followComponent(
  PositionComponent component, {
  Anchor relativeOffset = Anchor.center,
  Rect? worldBounds,
}) {
  print('followComponent method not work in Bonfire. Use moveToTarget');
}