BarLifeComponent constructor
BarLifeComponent({
- required Vector2 size,
- Attackable? target,
- Vector2? offset,
- Vector2? textOffset,
- BarLifePorition drawPosition = BarLifePorition.top,
- double margin = 4,
- List<
Color> ? colors, - TextStyle? textStyle,
- bool showLifeText = true,
- Color backgroundColor = const Color(0xFF000000),
- BorderRadius borderRadius = BorderRadius.zero,
- double borderWidth = 2,
- Color borderColor = const Color(0xFFFFFFFF),
- BarLifeTextBuilder? barLifetextBuilder,
- double life = 100,
- 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,
);
}