ScaleManager: do not apply new size if width is zero

If the game width reaches zero (e.g by resizing a cowebsite manually),
a division by zero happens when calculating the new zoom.
This results in NaN, which causes phaser to reach an invalid state when rezooming.
This commit is contained in:
Tobias Tefke 2022-01-03 09:07:09 +01:00
parent 8059af43e9
commit 0603d08572

View file

@ -31,6 +31,10 @@ export class WaScaleManager {
height: height * devicePixelRatio,
});
if (gameSize.width == 0) {
return;
}
this.actualZoom = realSize.width / gameSize.width / devicePixelRatio;
this.scaleManager.setZoom(realSize.width / gameSize.width / devicePixelRatio);