BarLifeComponent constructor

BarLifeComponent({
  1. required Vector2 size,
  2. Attackable? target,
  3. Vector2? offset,
  4. Vector2? textOffset,
  5. BarLifePorition drawPosition = BarLifePorition.top,
  6. double margin = 4,
  7. List<Color>? colors,
  8. TextStyle? textStyle,
  9. bool showLifeText = true,
  10. Color backgroundColor = const Color(0xFF000000),
  11. BorderRadius borderRadius = BorderRadius.zero,
  12. double borderWidth = 2,
  13. Color borderColor = const Color(0xFFFFFFFF),
  14. BarLifeTextBuilder? barLifetextBuilder,
  15. double life = 100,
  16. double maxLife = 100,
})

Implementation

BarLifeComponent({
  required Vector2 size,
  Attackable? target,
  Vector2? offset,
  Vector2? textOffset,
  this.drawPosition = BarLifePorition.top,
  this.margin = 4,
  this.colors,
  this.textStyle,
  this.showLifeText = true,
  this.backgroundColor = const Color(0xFF000000),
  this.borderRadius = BorderRadius.zero,
  this.borderWidth = 2,
  this.borderColor = const Color(0xFFFFFFFF),
  this.barLifetextBuilder,
  double life = 100,
  double maxLife = 100,
}) {
  _life = life;
  _maxLife = maxLife;
  _textOffset = textOffset ?? _textOffset;
  _barLiveBorderPaint = _barLiveBorderPaint
    ..color = borderColor
    ..strokeWidth = borderWidth
    ..style = PaintingStyle.stroke;

  _barLiveBgPaint = _barLiveBgPaint
    ..color = backgroundColor
    ..style = PaintingStyle.fill;

  this.size = size;

  _textConfig = TextPaint(
    style: textStyle?.copyWith(fontSize: size.y * 0.8) ??
        TextStyle(fontSize: size.y * 0.8, color: Colors.white),
  );

  _textSize = _textConfig.measureText(_getLifeText());

  setupFollower(
    target: target,
    offset: offset,
  );
}