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 = EdgeInsets.zero,
  9. Color color = Colors.blueGrey,
  10. JoystickActionAlign align = JoystickActionAlign.BOTTOM_RIGHT,
  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 = EdgeInsets.zero,
  this.color = Colors.blueGrey,
  this.align = JoystickActionAlign.BOTTOM_RIGHT,
  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;
}