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();