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.
 
 

42 lines
935 B

import Phaser from "phaser";
import PlayScene from "./scenes/PlayScene";
//import { * } from "./constant";
function launch({ containerId, onLose, onWon }) {
const container = document.getElementById(containerId);
const width = container.clientWidth;
const height = container.clientHeight;
const game = new Phaser.Game({
type: Phaser.CANVAS,
width,
height,
parent: containerId,
backgroundColor: 0xbbada0,
physics: {
default: "arcade",
arcade: {
//gravity: { y: 300 },
debug: false,
},
},
scene: PlayScene,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
parent: containerId,
width: 1080,
height: 1080,
},
});
Object.assign(game, {
onLose,
onWon,
restart() {
this.scene.scenes[0].scene.start("PlayScene");
},
});
return game;
}
export default launch;
export { launch };