examples/moire: Bug fix: Crash on browsers

Fixes #973
This commit is contained in:
Hajime Hoshi 2019-10-27 17:00:11 +09:00
parent 93792a6386
commit b8da9cf041

View File

@ -70,6 +70,8 @@ func update(screen *ebiten.Image) error {
screenScale = 2
case 2:
screenScale = 1
case 0:
// screenScale can be 0 on browsers or mobiles. Ignore this.
default:
panic("not reached")
}
@ -77,7 +79,9 @@ func update(screen *ebiten.Image) error {
if inpututil.IsKeyJustPressed(ebiten.KeyF) {
fullscreen = !fullscreen
}
ebiten.SetScreenScale(screenScale)
if screenScale > 0 {
ebiten.SetScreenScale(screenScale)
}
ebiten.SetFullscreen(fullscreen)
if ebiten.IsDrawingSkipped() {