JoystickComponent constructor

JoystickComponent({
  1. PositionComponent? knob,
  2. PositionComponent? background,
  3. EdgeInsets? margin,
  4. Vector2? position,
  5. double? size,
  6. double? knobRadius,
  7. Anchor anchor = Anchor.center,
  8. int? priority,
})

Implementation

JoystickComponent({
  this.knob,
  this.background,
  EdgeInsets? margin,
  Vector2? position,
  double? size,
  double? knobRadius,
  Anchor anchor = Anchor.center,
  int? priority,
})  : assert(
        size != null || background != null,
        'Either size or background must be defined',
      ),
      assert(
        (knob?.position.isZero() ?? true) &&
            (background?.position.isZero() ?? true),
        'Positions should not be set for the knob or the background',
      ),
      super(
        margin: margin,
        position: position,
        size: background?.size ?? Vector2.all(size ?? 0),
        anchor: anchor,
        priority: priority,
      ) {
  this.knobRadius = knobRadius ?? this.size.x / 2;
}