Automatically resizing game when window is resized
authorDavid Négrier <d.negrier@thecodingmachine.com>
Fri, 3 Apr 2020 16:41:06 +0000 (18:41 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Fri, 3 Apr 2020 16:41:06 +0000 (18:41 +0200)
front/src/index.ts

index 4a1c30315421a3344dfbcd977edd8371aae76420..ace0fa36ddefaaf83cfe2332985aab52363b63cf 100644 (file)
@@ -14,3 +14,7 @@ const config: GameConfig = {
 };
 
 let game = new Phaser.Game(config);
+
+window.addEventListener('resize', function (event) {
+    game.scale.resize(window.innerWidth / resolution, window.innerHeight / resolution);
+}