class GameOverScene extends Phaser.Scene {
    constructor() {
        super("GameOverScene");
    }

    preload() {
        this.load.image("gameover", "assets/gameover.png");
    }

    create(data) {
        var score = data.score;
        var r = this.input.keyboard.addKey("R");
        this.add.image(346/2, 240/2, "gameover");
        var wintext = (score == 0 ? "You didn't get any apples!" :
                       (score == 1 ? "You managed to grab an apple!" :
                        "You got " + score + " apples! Nice!"));
        this.add.text(32, 200, wintext, {
            fontFamily: "sans-serif",
            color: "#111111"
        }).setStroke("#ffffff", 2);
        this.add.text(32, 220, "Press R to restart", {
            fontFamily: "sans-serif",
            color: "#111111"
        }).setStroke("#ffffff", 2);
        r.on("up", function() {
            this.scene.start("GardenScene");
        }, this);
    }
}
