simpleAttackMelee method

void simpleAttackMelee({
  1. required double damage,
  2. required Vector2 size,
  3. int? id,
  4. int interval = 1000,
  5. bool withPush = false,
  6. double? sizePush,
  7. Direction? direction,
  8. Future<SpriteAnimation>? animationRight,
  9. VoidCallback? execute,
  10. Vector2? centerOffset,
})

Execute simple attack melee using animation

Implementation

void simpleAttackMelee({
  required double damage,
  required Vector2 size,
  int? id,
  int interval = 1000,
  bool withPush = false,
  double? sizePush,
  Direction? direction,
  Future<SpriteAnimation>? animationRight,
  VoidCallback? execute,
  Vector2? centerOffset,
}) {
  if (!checkInterval('attackMelee', interval, dtUpdate)) return;

  if (isDead) return;

  Direction direct = direction ??
      (gameRef.player != null
          ? getComponentDirectionFromMe(gameRef.player!)
          : lastDirection);

  simpleAttackMeleeByDirection(
    damage: damage,
    direction: direct,
    size: size,
    id: id,
    withPush: withPush,
    sizePush: sizePush,
    animationRight: animationRight,
    attackFrom: AttackOriginEnum.ENEMY,
    centerOffset: centerOffset,
  );

  execute?.call();
}