From c5875f2094381c9aa43267d9cc13ec55d5c43682 Mon Sep 17 00:00:00 2001 From: jiannibang Date: Fri, 28 Aug 2020 17:04:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A22d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- games/game-ballmove/game.js | 2 +- games/game-flipbird/game.js | 2 +- games/game-flood-fill/game.js | 2 +- games/game-flood-fill/scenes/PlayScene.js | 4 +--- games/game-rect/game.js | 2 +- games/game-rect/scenes/Rect.js | 9 ++++----- games/game2048/game.js | 2 +- phaser.js | 5 ++--- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/games/game-ballmove/game.js b/games/game-ballmove/game.js index 7747606..d64c401 100644 --- a/games/game-ballmove/game.js +++ b/games/game-ballmove/game.js @@ -6,7 +6,7 @@ function launch({ containerId, onLose }) { const width = container.clientWidth; const height = container.clientHeight; const game = new Phaser.Game({ - type: Phaser.AUTO, + type: Phaser.CANVAS, width, height, parent: containerId, diff --git a/games/game-flipbird/game.js b/games/game-flipbird/game.js index 63a80ef..943f21b 100644 --- a/games/game-flipbird/game.js +++ b/games/game-flipbird/game.js @@ -6,7 +6,7 @@ function launch({ containerId, onLose }) { const width = container.clientWidth; const height = container.clientHeight; const game = new Phaser.Game({ - type: Phaser.AUTO, + type: Phaser.CANVAS, width, height, parent: containerId, diff --git a/games/game-flood-fill/game.js b/games/game-flood-fill/game.js index f6df0b3..4ffddfa 100644 --- a/games/game-flood-fill/game.js +++ b/games/game-flood-fill/game.js @@ -7,7 +7,7 @@ function launch({ containerId, onLose, onWon }) { const width = container.clientWidth; const height = container.clientHeight; const game = new Phaser.Game({ - type: Phaser.WEBGL, + type: Phaser.CANVAS, width, height, parent: containerId, diff --git a/games/game-flood-fill/scenes/PlayScene.js b/games/game-flood-fill/scenes/PlayScene.js index 63d8bec..f6ac408 100644 --- a/games/game-flood-fill/scenes/PlayScene.js +++ b/games/game-flood-fill/scenes/PlayScene.js @@ -111,9 +111,7 @@ class PlayScene extends Phaser.Scene { this.text2 = this.add .text(590, 160, "00", { fontSize: 40, color: "#fff" }) .setAlpha(0); - this.text3 = this.add - .text(180, 200, "差一点!\n\n点击\n再试一次", 48) - .setAlpha(0); + this.text3 = this.add.text(180, 200, "", 48).setAlpha(0); this.instructions = this.add.image(500, 600, "instruction").setAlpha(0); //初始化位置 diff --git a/games/game-rect/game.js b/games/game-rect/game.js index 8c6aebd..dee76cc 100644 --- a/games/game-rect/game.js +++ b/games/game-rect/game.js @@ -7,7 +7,7 @@ function launch({ containerId, onLose }) { const height = container.clientHeight; const game = new Phaser.Game({ - type: Phaser.AUTO, + type: Phaser.CANVAS, width, height, parent: containerId, diff --git a/games/game-rect/scenes/Rect.js b/games/game-rect/scenes/Rect.js index 08794a1..dbbc5de 100644 --- a/games/game-rect/scenes/Rect.js +++ b/games/game-rect/scenes/Rect.js @@ -56,14 +56,13 @@ export default class Rect extends Phaser.Scene { // physics group which manages all tiles in game this.tileGroup = this.physics.add.group(); - const shape = this.add.graphics(); - shape.fillStyle = "#000"; + const shape = this.make.graphics(); shape.beginPath(); - shape.moveTo(0, tileSize * 8 + tileSpace * 7 + offsetTop); + shape.moveTo(0, offsetTop); + shape.lineTo(1080, offsetTop); shape.lineTo(1080, tileSize * 8 + tileSpace * 7 + offsetTop); - shape.lineTo(1080, 1080); - shape.lineTo(0, 1080); shape.lineTo(0, tileSize * 8 + tileSpace * 7 + offsetTop); + shape.lineTo(0, offsetTop); shape.fillPath(); const mask = shape.createGeometryMask(); diff --git a/games/game2048/game.js b/games/game2048/game.js index e9d7689..0abfb5b 100644 --- a/games/game2048/game.js +++ b/games/game2048/game.js @@ -6,7 +6,7 @@ function launch({ containerId, onLose }) { const width = container.clientWidth; const height = container.clientHeight; const game = new Phaser.Game({ - type: Phaser.AUTO, + type: Phaser.CANVAS, width, height, parent: containerId, diff --git a/phaser.js b/phaser.js index c6e42e2..cbf2068 100644 --- a/phaser.js +++ b/phaser.js @@ -3,9 +3,8 @@ import flappyBird from "./games/game-flipbird/game"; import game2048 from "./games/game2048/game"; import rect from "./games/game-rect/game"; import floodFill from "./games/game-flood-fill/game"; -const canvas = document.createElement("canvas"); -const attachMethods = (fn) => (config) => - Object.assign(fn(Object.assign(config, { canvas })), { +const attachMethods = (fn) => (...p) => + Object.assign(fn(...p), { pause() { this.scene.scenes.forEach((scene) => { scene.scene.pause();