simpleAttackMeleeByDirection method

void simpleAttackMeleeByDirection({
  1. Future<SpriteAnimation>? animationRight,
  2. dynamic id,
  3. required double damage,
  4. required Direction direction,
  5. required Vector2 size,
  6. required AttackOriginEnum attackFrom,
  7. bool withPush = true,
  8. double? sizePush,
  9. double? marginFromCenter,
  10. Vector2? centerOffset,
  11. void onDamage(
    1. Attackable attackable
    )?,
})

Execute simple attack melee using animation

Implementation

void simpleAttackMeleeByDirection({
  Future<SpriteAnimation>? animationRight,
  dynamic id,
  required double damage,
  required Direction direction,
  required Vector2 size,
  required AttackOriginEnum attackFrom,
  bool withPush = true,
  double? sizePush,
  double? marginFromCenter,
  Vector2? centerOffset,
  void Function(Attackable attackable)? onDamage,
}) {
  final rect = rectCollision;
  simpleAttackMeleeByAngle(
    angle: direction.toRadians(),
    animation: animationRight,
    attackFrom: attackFrom,
    damage: damage,
    size: size,
    centerOffset: centerOffset,
    marginFromCenter: marginFromCenter ?? max(rect.width, rect.height) / 2,
    id: id,
    withPush: withPush,
    onDamage: onDamage,
  );
}