FlyingAttackAngleObject constructor

FlyingAttackAngleObject({
  1. required Vector2 position,
  2. required Future<SpriteAnimation> flyAnimation,
  3. required double radAngle,
  4. required double width,
  5. required double height,
  6. dynamic id,
  7. Future<SpriteAnimation>? destroyAnimation,
  8. double speed = 150,
  9. double damage = 1,
  10. AttackFromEnum attackFrom = AttackFromEnum.ENEMY,
  11. bool withCollision = true,
  12. VoidCallback? onDestroy,
  13. LightingConfig? lightingConfig,
  14. CollisionConfig? collision,
})

Implementation

FlyingAttackAngleObject({
  required Vector2 position,
  required Future<SpriteAnimation> flyAnimation,
  required this.radAngle,
  required this.width,
  required this.height,
  this.id,
  this.destroyAnimation,
  this.speed = 150,
  this.damage = 1,
  this.attackFrom = AttackFromEnum.ENEMY,
  this.withCollision = true,
  this.onDestroy,
  LightingConfig? lightingConfig,
  CollisionConfig? collision,
}) {
  _loader.add(AssetToLoad(flyAnimation, (value) {
    return this.flyAnimation = value;
  }));

  this.position = Vector2Rect(
    position,
    Vector2(width, height),
  );

  if (lightingConfig != null) setupLighting(lightingConfig);

  setupCollision(
    collision ??
        CollisionConfig(
          collisions: [
            CollisionArea.rectangle(size: Size(width, height)),
          ],
        ),
  );

  _cosAngle = cos(radAngle);
  _senAngle = sin(radAngle);
  angle = radAngle + (pi / 2);
}