CircleButtonComponent constructor

CircleButtonComponent({
  1. required void onPressed(),
  2. String? label,
  3. required double radius,
  4. required Vector2? position,
  5. required Color color,
  6. PaintingStyle paintStyle = PaintingStyle.fill,
  7. Sprite? sprite,
  8. Color? pressedColor,
  9. Color textColor = Colors.white,
})

Creates a CircleButtonComponent.

onPressed is the callback triggered when the button is pressed. label is the text displayed on the button. sprite is the sprite displayed on the button. radius and position define the size and position of the button. color is the default background color. pressedColor is the background color when pressed. Defaults to color. textColor is the color of the label text.

Implementation

CircleButtonComponent({
  required this.onPressed,
  String? label,
  required this.radius,
  required super.position,
  required this.color,
  this.paintStyle = PaintingStyle.fill,
  Sprite? sprite,
  Color? pressedColor,
  this.textColor = Colors.white,
}) : assert(radius > 0, 'Radius must be greater than zero'),
     assert(
       sprite == null || label == null,
       'Cannot set both sprite and label on CircleButtonComponent',
     ),
     _label = label,
     _sprite = sprite,
     pressedColor = pressedColor ?? color,
     paint =
         Paint()
           ..color = color
           ..style = paintStyle;