TextDamageComponent constructor
TextDamageComponent(})
Implementation
TextDamageComponent(
String text,
Vector2 position, {
this.onlyUp = false,
TextStyle? config,
double initVelocityVertical = -4,
double initVelocityHorizontal = 1,
this.maxDownSize = 20,
this.gravity = 0.5,
this.direction = DirectionTextDamage.RANDOM,
}) : super(
text: text,
textRenderer: TextPaint(
style: config,
),
position: position,
) {
_initialY = position.y;
_velocity = initVelocityVertical;
switch (direction) {
case DirectionTextDamage.LEFT:
_moveAxisX = initVelocityHorizontal;
break;
case DirectionTextDamage.RIGHT:
_moveAxisX = initVelocityHorizontal * -1;
break;
case DirectionTextDamage.RANDOM:
_moveAxisX =
initVelocityHorizontal * Random().nextInt(100) % 2 == 0 ? -1 : 1;
break;
case DirectionTextDamage.NONE:
break;
}
}