examples/windowsize: Bug fix: screenScale can be 0 on browsers

This commit is contained in:
Hajime Hoshi 2019-12-22 19:20:31 +09:00
parent 812a29bf07
commit 4aa80de34d

View File

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