FlyingAttackObject.byAngle constructor

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

Implementation

FlyingAttackObject.byAngle({
  required Vector2 position,
  required Vector2 size,
  required Future<SpriteAnimation> flyAnimation,
  required double angle,
  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,
}) : direction = null {
  loader?.add(AssetToLoad(flyAnimation, (value) {
    return 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),
            ),
          ],
        ),
  );
}