Files
MI2Mario/src/index.js
T
2020-07-16 04:42:39 +02:00

48 lines
1.3 KiB
JavaScript

/*
* Copyright (c) 2020. Antonio Martinez Casadesus and Pascal Syma.
* All rights reserved.
*/
import Phaser from "phaser";
import Menu from "./scenes/Menu";
import Preload from "./scenes/Preload";
import Game from "./scenes/Game";
import ControlsSettings from "./scenes/ControlsSettings";
import RexUIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin.js';
import GUI from "./scenes/GUI";
const ratio = 16 / 9; // any ratio you want, 16/9 landscape or 9/16 portrait
const DEFAULT_HEIGHT = 1080 / 4; // any height you want
const DEFAULT_WIDTH = ratio * DEFAULT_HEIGHT;
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
height: DEFAULT_HEIGHT,
width: DEFAULT_WIDTH,
parent: "phaser-example",
scene: [Preload, GUI, Menu, ControlsSettings, Game],
pixelArt: true,
antialias: false,
autoFocus: true,
roundPixels: true,
plugins: {
scene: [{
key: 'rexUI',
plugin: RexUIPlugin,
mapping: 'rexUI'
}]
}
};
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./service-worker.js').then();
});
}
const game = new Phaser.Game(config);