import Level from "../scenes/Level";

export class StarFactory {
    scene: Level;

    constructor(scene: Level) {
        this.scene = scene;
    }

    create(group: Phaser.Physics.Arcade.Group, x: number, y: number) {
        const star = new Star(this.scene, x, y);
        group.add(star);
        return star;
    }
}

export class Star extends Phaser.Physics.Arcade.Sprite {
    scene: Level;

    constructor(scene: Level, x: number, y: number) {
        super(scene, x, y, "star");
        this.scene = scene;
        scene.add.existing(this);
        scene.physics.add.existing(this);

        this.init();
        this.scene.events.on(Phaser.Scenes.Events.UPDATE, this.update, this);
    }

    init() {
        this
            .setOrigin(0.5, 0.5)
            .setCollideWorldBounds(true)
            .setDisplaySize(64, 64)
            .setDepth(2);
    }


    update() {

    }
}
