showDamage method
void
showDamage(})
Add in the game a text with animation representing damage received
Implementation
void showDamage(
double damage, {
TextStyle? config,
double initVelocityVertical = -5,
double initVelocityHorizontal = 1,
double gravity = 0.5,
double maxDownSize = 20,
DirectionTextDamage direction = DirectionTextDamage.RANDOM,
bool onlyUp = false,
}) {
if (!hasGameRef) return;
gameRef.add(
TextDamageComponent(
damage.toInt().toString(),
Vector2(rectCollision.center.dx, rectCollision.top),
config: config ??
const TextStyle(
fontSize: 14,
color: Color(0xFFFFFFFF),
),
initVelocityVertical: initVelocityVertical,
initVelocityHorizontal: initVelocityHorizontal,
gravity: gravity,
direction: direction,
onlyUp: onlyUp,
maxDownSize: maxDownSize,
),
);
}