From 4aa80de34d2fa8a9ecd68c5fea999886d75202c9 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 22 Dec 2019 19:20:31 +0900 Subject: [PATCH] examples/windowsize: Bug fix: screenScale can be 0 on browsers --- examples/windowsize/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index 3b1ec74a0..932adcd28 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -115,7 +115,12 @@ func (g *game) Update(screen *ebiten.Image) error { screenWidth = g.width screenHeight = g.height ww, _ := ebiten.WindowSize() - screenScale = float64(ww) / float64(g.width) + if ww > 0 { + screenScale = float64(ww) / float64(g.width) + } else { + // ebiten.WindowSize can return (0, 0) on browsers or mobiles. + screenScale = 1 + } } fullscreen := ebiten.IsFullscreen()