JoystickComponent constructor
JoystickComponent({
- PositionComponent? knob,
- PositionComponent? background,
- EdgeInsets? margin,
- Vector2? position,
- double? size,
- double? knobRadius,
- Anchor anchor = Anchor.center,
- 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;
}