addJoystickObserver method

  1. @override
void addJoystickObserver(
  1. GameComponent 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(
  GameComponent target, {
  bool cleanObservers = false,
  bool moveCameraToTarget = false,
}) {
  if (target is JoystickListener) {
    if (cleanObservers) {
      _joystickController?.cleanObservers();
    }
    _joystickController?.addObserver(target as JoystickListener);
    if (moveCameraToTarget) {
      camera.moveToTargetAnimated(target);
    }
  } else {
    print('$target is not a JoystickListener');
  }
}