From 613ff5d463cb69ad90f2d955660d96074983d446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 4 May 2021 12:09:00 +0200 Subject: [PATCH] Adding zoom out limit --- front/src/Phaser/Services/HdpiManager.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/front/src/Phaser/Services/HdpiManager.ts b/front/src/Phaser/Services/HdpiManager.ts index 6ffad8cd..1cc97634 100644 --- a/front/src/Phaser/Services/HdpiManager.ts +++ b/front/src/Phaser/Services/HdpiManager.ts @@ -41,6 +41,23 @@ export class HdpiManager { i++; } + // Has the canvas more pixels than the screen? This is forbidden + if ((i - 1) * this._zoomModifier < 1) { + // Let's reset the zoom modifier (WARNING this is a SIDE EFFECT in a getter) + this._zoomModifier = 1 / (i - 1); + + return { + game: { + width: realPixelScreenSize.width, + height: realPixelScreenSize.height, + }, + real: { + width: realPixelScreenSize.width, + height: realPixelScreenSize.height, + } + } + } + return { game: { width: Math.ceil(realPixelScreenSize.width / (i - 1) / this._zoomModifier),