FlyingAttackObject constructor

FlyingAttackObject({
  1. required Vector2 position,
  2. required Vector2 size,
  3. required Future<SpriteAnimation> flyAnimation,
  4. Direction? direction,
  5. double angle = 0,
  6. dynamic id,
  7. Future<SpriteAnimation>? animationDestroy,
  8. Vector2? destroySize,
  9. double speed = 150,
  10. double damage = 1,
  11. AttackFromEnum attackFrom = AttackFromEnum.ENEMY,
  12. bool withDecorationCollision = true,
  13. VoidCallback? onDestroy,
  14. bool enabledDiagonal = true,
  15. LightingConfig? lightingConfig,
  16. CollisionConfig? collision,
})

Implementation

FlyingAttackObject({
  required Vector2 position,
  required Vector2 size,
  required Future<SpriteAnimation> flyAnimation,
  this.direction,
  double angle = 0,
  this.id,
  this.animationDestroy,
  this.destroySize,
  this.speed = 150,
  this.damage = 1,
  this.attackFrom = AttackFromEnum.ENEMY,
  this.withDecorationCollision = true,
  this.onDestroy,
  this.enabledDiagonal = true,
  LightingConfig? lightingConfig,
  CollisionConfig? collision,
}) {
  loader?.add(AssetToLoad(flyAnimation, (value) {
    this.flyAnimation = value;
  }));

  this.position = position;
  this.size = size;
  this.angle = angle;
  _cosAngle = cos(angle);
  _senAngle = sin(angle);

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

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