From 6186f4af262e3fcff6d8352287882d68024f9f78 Mon Sep 17 00:00:00 2001 From: jiannibang Date: Mon, 7 Sep 2020 17:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=EF=BC=9A=E5=B0=8F=E9=B8=9F?= =?UTF-8?q?=E9=A3=9E=EF=BC=8C=E8=BE=93=E5=85=A5=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=8A=A0=E2=80=9C3=20=202=20=201=20=20?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E2=80=9D=E6=98=BE=E7=A4=BA=20=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=EF=BC=9A=E5=90=8C=E8=89=B2=E6=B6=88=E9=99=A4=EF=BC=8C?= =?UTF-8?q?=E5=86=8D=E6=9D=A5=E4=B8=80=E6=AC=A1=EF=BC=8C=E5=88=86=E6=95=B0?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=9D=E5=A7=8B=E5=8C=96=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0moves=EF=BC=9A-X=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game-flipbird/scenes/flipbird/flipbird.js | 36 ++++++++++++++++--- games/game-flood-fill/scenes/PlayScene.js | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/games/game-flipbird/scenes/flipbird/flipbird.js b/games/game-flipbird/scenes/flipbird/flipbird.js index 8566473..418555e 100644 --- a/games/game-flipbird/scenes/flipbird/flipbird.js +++ b/games/game-flipbird/scenes/flipbird/flipbird.js @@ -12,6 +12,7 @@ import bg from "../../assets/flipbird/bg.png"; */ const getRandomPipe = () => ["pipe1", "pipe2", "pipe3"][Math.floor(Math.random() * 3)]; +const wait1s = () => new Promise((resolve) => setTimeout(resolve, 1000)); export default class PlayScene extends Phaser.Scene { constructor() { super({ key: "flipbird" }); @@ -50,7 +51,7 @@ export default class PlayScene extends Phaser.Scene { frameHeight: 392, }); } - create() { + async create() { // this.game.physics.startSystem(Phaser.Physics.P2JS); this.bg = this.add.image( this.game.config.width / 2, @@ -74,7 +75,6 @@ export default class PlayScene extends Phaser.Scene { this.pipePool.push(p2); this.placePipes(false); } - this.pipeGroup.setVelocityX(-this.gameOptions.birdSpeed); this.bird = this.physics.add.sprite( 150, this.game.config.height / 2, @@ -83,20 +83,46 @@ export default class PlayScene extends Phaser.Scene { this.bird.body.setCircle(342 / 2, 0, 25); this.bird.setScale(0.5); - this.bird.body.gravity.y = this.gameOptions.birdGravity; - this.anims.create({ key: "fly", frames: this.anims.generateFrameNumbers("bird", { start: 0, end: 3 }), frameRate: 10, repeat: -1, }); - this.input.on("pointerdown", this.flap, this); + this.score = 0; this.scoreText1 = this.add.text(20, 20, "", { fontSize: 20, }); this.updateScore(this.score); + this.countDownWrapper = this.add.rectangle( + this.game.config.width / 2, + this.game.config.height / 2, + this.game.config.width, + this.game.config.height, + 0x000000, + 0.6 + ); + this.countDown = this.add.text( + this.game.config.width / 2, + this.game.config.height / 2, + "3", + { + fontSize: 110, + textAlign: "center", + baseLine: "middle", + } + ); + await wait1s(); + this.countDown.text = 2; + await wait1s(); + this.countDown.text = 1; + await wait1s(); + this.countDown.destroy(); + this.countDownWrapper.destroy(); + this.input.on("pointerdown", this.flap, this); + this.pipeGroup.setVelocityX(-this.gameOptions.birdSpeed); + this.bird.body.gravity.y = this.gameOptions.birdGravity; } updateScore(inc) { this.score += inc; diff --git a/games/game-flood-fill/scenes/PlayScene.js b/games/game-flood-fill/scenes/PlayScene.js index 1b35338..ae2f918 100644 --- a/games/game-flood-fill/scenes/PlayScene.js +++ b/games/game-flood-fill/scenes/PlayScene.js @@ -57,7 +57,7 @@ class PlayScene extends Phaser.Scene { this.createIcon(3, 1080 - 184, 272); this.createIcon(4, 1080 - 184, 272 + 252); this.createIcon(5, 1080 - 184, 272 + 252 * 2); - + this.moves = 25; // The game is played in a 14x14 grid with 6 different colors this.grid = [];