This commit fixes the close problem of the app

This commit is contained in:
Thibault Blanc Beyne 2018-08-22 17:42:19 +02:00
parent 1b19558a86
commit e271be8ea0
2 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,9 @@
class Game {
constructor(canvas) {
this.canvas = canvas;
// Create menu
let menu = new Menu(canvas);
@ -28,17 +31,20 @@ class Game {
if (this.mainScreen.after === AfterMenu.Start) {
this.changeScreen(this.scene);
} else if (this.mainScreen.after === AfterMenu.Exit) {
if (typeof window.close === 'function') {
window.close();
if (navigator.app !== undefined && typeof navigator.app.exitApp === 'function') {
navigator.app.exitApp();
}
// if (navigator.app !== undefined && typeof navigator.app.exitApp === 'function') {
// navigator.app.exitApp();
// }
}
}
}
render() {
this.autoResize();
this.mainScreen.render();
}
autoResize() {
this.canvas.width = window.innerWidth;
this.canvas.height = window.innerHeight;
}
}

View File

@ -1,4 +1,4 @@
let game;
let game, context;
init();
loop();