You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.4 KiB

import { Scene } from "phaser";
import bg from "@/game/game/assets/flipbird/bg.png";
import gameoverbg from "@/game/game/assets/flipbird/gameoverbg.png";
import gameover from "@/game/game/assets/flipbird/gameover.png";
export default class gameOverScene extends Scene {
constructor() {
super({ key: "flipBirdGameOver" });
this.score = "";
this.topScore = "";
}
init(data) {
//方法1. 引入sceneA 在初始化的时候就可以获得场景Scene传递的值;
this.score = data.score;
this.topScore = data.topScore;
}
preload() {
this.load.image("bg", bg);
this.load.image("gameoverbg", gameoverbg);
this.load.image("gameover", gameover);
}
create() {
this.bg = this.add.image(0, 0, "bg");
this.bg.setScale(3.1);
this.gameoverbg = this.add.image(
this.game.config.width / 2,
this.game.config.height / 2,
"gameoverbg"
);
this.gameover = this.add.image(
this.game.config.width / 2,
this.game.config.height / 2 - 80,
"gameover"
);
this.scoreText = this.add.text(
this.game.config.width / 2,
this.game.config.height / 2 + 80,
"",
{ fontSize: "55px", fill: "black", fontWeight: 800 }
);
this.scoreText.setOrigin(0.5);
this.scoreText.text = "Score: " + this.score + "\nBest: " + this.topScore;
this.bg.setInteractive();
this.bg.on("pointerdown", () => {
this.scene.start("flipbird");
})
}
}