-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
88 lines (80 loc) · 1.58 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import './style.css';
import { Game, WEBGL, Scale } from 'phaser';
// import { StatusBar } from '@capacitor/status-bar';
import { Boot } from './scenes/Boot';
import { Demo } from './scenes/Demo';
import { Hud } from './scenes/Hud';
import { Title } from './scenes/Title';
import { audioContext } from './utils/ffmpeg';
const canvas = document.getElementById('game');
const config = {
type: WEBGL,
canvas,
dom: {
createContainer: true
},
input: {
mouse: {
target: 'game'
},
touch: {
target: 'game'
}
}
,
width: 720,
height: 720,
scale: {
parent: document.querySelector('body'),
mode: Scale.FIT
},
physics: {
default: 'arcade',
arcade: {
gravity: { y: 800 },
// debug: true
}
},
input: {
gamepad: true
},
scene: [
Boot,
Title,
Demo,
Hud
],
pixelArt: true,
audio: {
context: audioContext
}
}
function boot() {
// try {
// await StatusBar.hide();
// }
// catch (e) {
// console.warn(e);
// }
new Game(config);
// canvas.style.display = 'none';
}
boot();
document.addEventListener('contextmenu', e => e.preventDefault());
window.addEventListener('touchstart', () => {
document.documentElement.classList.remove('novirtual');
});
const doc = document.documentElement;
document.addEventListener('click', () => {
if (!document.fullscreenElement) {
doc.requestFullscreen();
}
});
document.addEventListener('fullscreenchange', () => {
if (document.fullscreenElement) {
doc.classList.add('no_cursor');
}
else {
doc.classList.remove('no_cursor');
}
});