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