import { Physics } from 'phaser';

export class PropellerHat extends Physics.Arcade.Sprite {
  constructor(scene, x, y) {
    super(scene, x, y, 'propeller_hat');
    scene.add.existing(this);
    scene.physics.add.existing(this, true);

    this.setScale(0.45);
    this.body.setSize(this.width * 0.7, this.height * 0.5);
    this.body.setOffset(this.width * 0.15, this.height * 0.25);
    this.consumed = false;
  }

  onPlayerTouch(player) {
    if (this.consumed) return false;
    this.consumed = true;
    this.body.enable = false;
    this.setVisible(false);
    player.startPropeller();
    this.destroy();
    return true;
  }
}
