FlyingAttackObject constructor

FlyingAttackObject({
  1. required Vector2 position,
  2. required Future<SpriteAnimation> flyAnimation,
  3. required Direction direction,
  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 withDecorationCollision = true,
  12. VoidCallback? onDestroyedObject,
  13. bool enableDiagonal = true,
  14. LightingConfig? lightingConfig,
  15. CollisionConfig? collision,
})

Implementation

FlyingAttackObject({
  required Vector2 position,
  required Future<SpriteAnimation> flyAnimation,
  required this.direction,
  required this.width,
  required this.height,
  this.id,
  this.destroyAnimation,
  this.speed = 150,
  this.damage = 1,
  this.attackFrom = AttackFromEnum.ENEMY,
  this.withDecorationCollision = true,
  this.onDestroyedObject,
  this.enableDiagonal = true,
  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),
            ),
          ],
        ),
  );
}