simpleAttackRangeByAngle method
void
simpleAttackRangeByAngle({
- required Future<
SpriteAnimation> animation, - required Vector2 size,
- required double angle,
- required double damage,
- required AttackOriginEnum attackFrom,
- Vector2? destroySize,
- Future<
SpriteAnimation> ? animationDestroy, - dynamic id,
- double speed = 150,
- bool withDecorationCollision = true,
- VoidCallback? onDestroy,
- ShapeHitbox? 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 AttackOriginEnum attackFrom,
Vector2? destroySize,
Future<SpriteAnimation>? animationDestroy,
dynamic id,
double speed = 150,
bool withDecorationCollision = true,
VoidCallback? onDestroy,
ShapeHitbox? collision,
LightingConfig? lightingConfig,
double marginFromOrigin = 16,
Vector2? centerOffset,
}) {
var initPosition = rectCollision;
Vector2 startPosition =
initPosition.center.toVector2() + (centerOffset ?? Vector2.zero());
double displacement =
max(initPosition.width, initPosition.height) / 2 + marginFromOrigin;
startPosition = BonfireUtil.movePointByAngle(
startPosition,
displacement,
angle,
);
gameRef.add(
FlyingAttackGameObject.byAngle(
id: id,
position: startPosition,
size: size,
angle: angle,
damage: damage,
speed: speed,
attackFrom: attackFrom,
collision: collision,
withDecorationCollision: withDecorationCollision,
onDestroy: onDestroy,
destroySize: destroySize,
animation: animation,
animationDestroy: animationDestroy,
lightingConfig: lightingConfig,
),
);
}