JoystickAction constructor
JoystickAction({
- required dynamic actionId,
- Future<
Sprite> ? sprite, - Future<
Sprite> ? spritePressed, - Future<
Sprite> ? spriteBackgroundDirection, - bool enableDirection = false,
- double size = 50,
- double sizeFactorBackgroundDirection = 1.5,
- EdgeInsets margin = const EdgeInsets.all(50),
- Color color = Colors.blueGrey,
- Alignment alignment = Alignment.bottomRight,
- double opacityBackground = 0.5,
- double opacityKnob = 0.8,
Implementation
JoystickAction({
required this.actionId,
Future<Sprite>? sprite,
Future<Sprite>? spritePressed,
Future<Sprite>? spriteBackgroundDirection,
this.enableDirection = false,
this.size = 50,
this.sizeFactorBackgroundDirection = 1.5,
this.margin = const EdgeInsets.all(50),
this.color = Colors.blueGrey,
this.alignment = Alignment.bottomRight,
this.opacityBackground = 0.5,
this.opacityKnob = 0.8,
}) {
_loader?.add(AssetToLoad(sprite, (value) {
this.sprite = value;
}));
_loader?.add(AssetToLoad(spritePressed, (value) {
this.spritePressed = value;
}));
_loader?.add(AssetToLoad(spriteBackgroundDirection, (value) {
this.spriteBackgroundDirection = value;
}));
_sizeBackgroundDirection = sizeFactorBackgroundDirection * size;
_tileSize = _sizeBackgroundDirection / 2;
}