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.
 
 

38 lines
817 B

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