melee method
void
melee({})
Executes a melee attack. If angle (radians) is provided the attack is
performed in that direction, otherwise direction is used (defaults to
the player, the component direction or the last movement direction).
Implementation
void melee({
required double damage,
required Vector2 size,
Future<SpriteAnimation>? animation,
dynamic id,
Direction? direction,
double? angle,
bool withPush = true,
double? sizePush,
Vector2? centerOffset,
double? marginFromCenter,
bool diagonalEnabled = true,
AttackOriginEnum? attackFrom,
}) {
final origin = attackFrom ?? _defaultAttackFrom();
if (angle != null) {
meleeByAngle(
damage: damage,
size: size,
animation: animation,
id: id,
angle: angle,
attackFrom: origin,
withPush: withPush,
centerOffset: centerOffset,
marginFromCenter: marginFromCenter ?? 0,
);
} else {
meleeByDirection(
damage: damage,
size: size,
animationRight: animation,
id: id,
direction: direction ?? _defaultMeleeDirection(diagonalEnabled),
attackFrom: origin,
withPush: withPush,
sizePush: sizePush,
centerOffset: centerOffset,
marginFromCenter: marginFromCenter,
);
}
}