simpleAttackRangeByAngle method
void
simpleAttackRangeByAngle({
- required Future<
SpriteAnimation> animation, - required Vector2 size,
- required double angle,
- required double damage,
- required AttackFromEnum attackFrom,
- Vector2? destroySize,
- Future<
SpriteAnimation> ? animationDestroy, - dynamic id,
- double speed = 150,
- bool withDecorationCollision = true,
- VoidCallback? onDestroy,
- CollisionConfig? collision,
- LightingConfig? lightingConfig,
- double marginFromOrigin = 16,
- Vector2? centerOffset,
Execute the ranged attack using a component with animation
Implementation
void simpleAttackRangeByAngle({
/// use animation facing right.
required Future<SpriteAnimation> animation,
required Vector2 size,
/// Use radians angle
required double angle,
required double damage,
required AttackFromEnum attackFrom,
Vector2? destroySize,
Future<SpriteAnimation>? animationDestroy,
dynamic id,
double speed = 150,
bool withDecorationCollision = true,
VoidCallback? onDestroy,
CollisionConfig? collision,
LightingConfig? lightingConfig,
double marginFromOrigin = 16,
Vector2? centerOffset,
}) {
var initPosition = rectConsideringCollision;
Vector2 startPosition =
initPosition.center.toVector2() + (centerOffset ?? Vector2.zero());
double displacement =
max(initPosition.width, initPosition.height) / 2 + marginFromOrigin;
startPosition = BonfireUtil.movePointByAngle(
startPosition,
displacement,
angle,
);
startPosition.add(Vector2(-size.x / 2, -size.y / 2));
gameRef.add(
FlyingAttackObject.byAngle(
id: id,
position: startPosition,
size: size,
angle: angle,
damage: damage,
speed: speed,
attackFrom: attackFrom,
collision: collision,
withDecorationCollision: withDecorationCollision,
onDestroy: onDestroy,
destroySize: destroySize,
flyAnimation: animation,
animationDestroy: animationDestroy,
lightingConfig: lightingConfig,
),
);
}