Browse Source

替换2d

master
jiannibang 6 years ago
parent
commit
c5875f2094
  1. 2
      games/game-ballmove/game.js
  2. 2
      games/game-flipbird/game.js
  3. 2
      games/game-flood-fill/game.js
  4. 4
      games/game-flood-fill/scenes/PlayScene.js
  5. 2
      games/game-rect/game.js
  6. 9
      games/game-rect/scenes/Rect.js
  7. 2
      games/game2048/game.js
  8. 5
      phaser.js

2
games/game-ballmove/game.js

@ -6,7 +6,7 @@ function launch({ containerId, onLose }) {
const width = container.clientWidth; const width = container.clientWidth;
const height = container.clientHeight; const height = container.clientHeight;
const game = new Phaser.Game({ const game = new Phaser.Game({
type: Phaser.AUTO,
type: Phaser.CANVAS,
width, width,
height, height,
parent: containerId, parent: containerId,

2
games/game-flipbird/game.js

@ -6,7 +6,7 @@ function launch({ containerId, onLose }) {
const width = container.clientWidth; const width = container.clientWidth;
const height = container.clientHeight; const height = container.clientHeight;
const game = new Phaser.Game({ const game = new Phaser.Game({
type: Phaser.AUTO,
type: Phaser.CANVAS,
width, width,
height, height,
parent: containerId, parent: containerId,

2
games/game-flood-fill/game.js

@ -7,7 +7,7 @@ function launch({ containerId, onLose, onWon }) {
const width = container.clientWidth; const width = container.clientWidth;
const height = container.clientHeight; const height = container.clientHeight;
const game = new Phaser.Game({ const game = new Phaser.Game({
type: Phaser.WEBGL,
type: Phaser.CANVAS,
width, width,
height, height,
parent: containerId, parent: containerId,

4
games/game-flood-fill/scenes/PlayScene.js

@ -111,9 +111,7 @@ class PlayScene extends Phaser.Scene {
this.text2 = this.add this.text2 = this.add
.text(590, 160, "00", { fontSize: 40, color: "#fff" }) .text(590, 160, "00", { fontSize: 40, color: "#fff" })
.setAlpha(0); .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); this.instructions = this.add.image(500, 600, "instruction").setAlpha(0);
//初始化位置 //初始化位置

2
games/game-rect/game.js

@ -7,7 +7,7 @@ function launch({ containerId, onLose }) {
const height = container.clientHeight; const height = container.clientHeight;
const game = new Phaser.Game({ const game = new Phaser.Game({
type: Phaser.AUTO,
type: Phaser.CANVAS,
width, width,
height, height,
parent: containerId, parent: containerId,

9
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 // physics group which manages all tiles in game
this.tileGroup = this.physics.add.group(); this.tileGroup = this.physics.add.group();
const shape = this.add.graphics();
shape.fillStyle = "#000";
const shape = this.make.graphics();
shape.beginPath(); 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, tileSize * 8 + tileSpace * 7 + offsetTop);
shape.lineTo(1080, 1080);
shape.lineTo(0, 1080);
shape.lineTo(0, tileSize * 8 + tileSpace * 7 + offsetTop); shape.lineTo(0, tileSize * 8 + tileSpace * 7 + offsetTop);
shape.lineTo(0, offsetTop);
shape.fillPath(); shape.fillPath();
const mask = shape.createGeometryMask(); const mask = shape.createGeometryMask();

2
games/game2048/game.js

@ -6,7 +6,7 @@ function launch({ containerId, onLose }) {
const width = container.clientWidth; const width = container.clientWidth;
const height = container.clientHeight; const height = container.clientHeight;
const game = new Phaser.Game({ const game = new Phaser.Game({
type: Phaser.AUTO,
type: Phaser.CANVAS,
width, width,
height, height,
parent: containerId, parent: containerId,

5
phaser.js

@ -3,9 +3,8 @@ import flappyBird from "./games/game-flipbird/game";
import game2048 from "./games/game2048/game"; import game2048 from "./games/game2048/game";
import rect from "./games/game-rect/game"; import rect from "./games/game-rect/game";
import floodFill from "./games/game-flood-fill/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() { pause() {
this.scene.scenes.forEach((scene) => { this.scene.scenes.forEach((scene) => {
scene.scene.pause(); scene.scene.pause();

Loading…
Cancel
Save