addJoystickObserver method

  1. @override
void addJoystickObserver(
  1. PlayerControllerListener target, {
  2. bool cleanObservers = false,
  3. bool moveCameraToTarget = false,
})
override

Use this method to change default observer of the Joystick events.

Implementation

@override
void addJoystickObserver(
  PlayerControllerListener target, {
  bool cleanObservers = false,
  bool moveCameraToTarget = false,
}) {
  if (cleanObservers) {
    playerControllers?.forEach(
      (c) => c.cleanObservers(),
    );
  }
  playerControllers?.forEach(
    (c) => c.addObserver(target),
  );
  if (moveCameraToTarget && target is GameComponent) {
    camera.follow(target as GameComponent);
  }
}