JoystickAction constructor

JoystickAction({
  1. required dynamic actionId,
  2. Future<Sprite>? sprite,
  3. Future<Sprite>? spritePressed,
  4. Future<Sprite>? spriteBackgroundDirection,
  5. bool enableDirection = false,
  6. double size = 50,
  7. double sizeFactorBackgroundDirection = 1.5,
  8. EdgeInsets margin = const EdgeInsets.all(50),
  9. Color color = Colors.blueGrey,
  10. Alignment alignment = Alignment.bottomRight,
  11. double opacityBackground = 0.5,
  12. 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;
}