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.
40 lines
1.1 KiB
40 lines
1.1 KiB
import ballMove from "./games/game-ballmove/game";
|
|
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";
|
|
import fishMaster from "./games/fishMaster/index";
|
|
const attachMethods = (fn) => (...p) =>
|
|
Object.assign(fn(...p), {
|
|
pause() {
|
|
this.scene.scenes.forEach((scene) => {
|
|
scene.scene.pause();
|
|
});
|
|
},
|
|
resume() {
|
|
this.scene.scenes.forEach((scene) => {
|
|
scene.scene.resume();
|
|
});
|
|
},
|
|
dispose() {
|
|
for (const key in this.scene.keys) {
|
|
if (this.scene.keys.hasOwnProperty(key)) {
|
|
this.scene.stop(key); //停止渲染
|
|
this.scene.keys[key] = undefined;
|
|
}
|
|
}
|
|
this.destroy(false);
|
|
},
|
|
});
|
|
const games = Object.entries({
|
|
ballMove,
|
|
flappyBird,
|
|
game2048,
|
|
rect,
|
|
floodFill,
|
|
fishMaster,
|
|
})
|
|
.map(([name, fn]) => ({ [name]: attachMethods(fn) }))
|
|
.reduce((acc, nxt) => Object.assign(acc, nxt), {});
|
|
|
|
export default games;
|
|
|