simpleAttackRangeByDirection method
void
simpleAttackRangeByDirection({
- required Future<
SpriteAnimation> animationRight, - required Vector2 size,
- required Direction direction,
- required AttackOriginEnum attackFrom,
- Vector2? destroySize,
- dynamic id,
- double speed = 150,
- double damage = 1,
- bool withCollision = true,
- VoidCallback? onDestroy,
- ShapeHitbox? collision,
- LightingConfig? lightingConfig,
- Future<
SpriteAnimation> ? animationDestroy, - double marginFromOrigin = 16,
- Vector2? centerOffset,
Execute the ranged attack using a component with animation
Implementation
void simpleAttackRangeByDirection({
required Future<SpriteAnimation> animationRight,
required Vector2 size,
required Direction direction,
required AttackOriginEnum attackFrom,
Vector2? destroySize,
dynamic id,
double speed = 150,
double damage = 1,
bool withCollision = true,
VoidCallback? onDestroy,
ShapeHitbox? collision,
LightingConfig? lightingConfig,
Future<SpriteAnimation>? animationDestroy,
double marginFromOrigin = 16,
Vector2? centerOffset,
}) {
final initPosition = rectCollision;
var startPosition =
initPosition.center.toVector2() + (centerOffset ?? Vector2.zero());
final displacement =
max(initPosition.width, initPosition.height) / 2 + marginFromOrigin;
startPosition = BonfireUtil.movePointByAngle(
startPosition,
displacement,
direction.toRadians(),
);
gameRef.add(
FlyingAttackGameObject.byDirection(
direction: direction,
animation: animationRight,
attackFrom: attackFrom,
damage: damage,
size: size,
animationDestroy: animationDestroy,
destroySize: destroySize,
id: id,
lightingConfig: lightingConfig,
onDestroy: onDestroy,
speed: speed,
withDecorationCollision: withCollision,
position: startPosition,
),
);
}