From e271be8ea0490233af6f58db586d45d8e817fae4 Mon Sep 17 00:00:00 2001 From: Thibault Blanc Beyne Date: Wed, 22 Aug 2018 17:42:19 +0200 Subject: [PATCH] This commit fixes the close problem of the app --- src/game.js | 16 +++++++++++----- src/main.js | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/game.js b/src/game.js index 6619cc7..520e4a9 100644 --- a/src/game.js +++ b/src/game.js @@ -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; + } } diff --git a/src/main.js b/src/main.js index 519cfe3..55945dd 100644 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,4 @@ -let game; +let game, context; init(); loop();