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 { class Game {
constructor(canvas) { constructor(canvas) {
this.canvas = canvas;
// Create menu // Create menu
let menu = new Menu(canvas); let menu = new Menu(canvas);
@ -28,17 +31,20 @@ class Game {
if (this.mainScreen.after === AfterMenu.Start) { if (this.mainScreen.after === AfterMenu.Start) {
this.changeScreen(this.scene); this.changeScreen(this.scene);
} else if (this.mainScreen.after === AfterMenu.Exit) { } else if (this.mainScreen.after === AfterMenu.Exit) {
if (typeof window.close === 'function') { if (navigator.app !== undefined && typeof navigator.app.exitApp === 'function') {
window.close(); navigator.app.exitApp();
} }
// if (navigator.app !== undefined && typeof navigator.app.exitApp === 'function') {
// navigator.app.exitApp();
// }
} }
} }
} }
render() { render() {
this.autoResize();
this.mainScreen.render(); 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(); init();
loop(); loop();