examples/fullscreen: enable to test on mobile browsers

Closes #2060
This commit is contained in:
Hajime Hoshi 2022-08-07 19:31:53 +09:00
parent abcacc26d8
commit 05dd36ec7b

View File

@ -34,6 +34,7 @@ import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"github.com/hajimehoshi/ebiten/v2/text"
)
@ -79,8 +80,10 @@ type Game struct {
func (g *Game) Update() error {
g.count++
if runtime.GOOS == "js" && ebiten.IsKeyPressed(ebiten.KeyF) {
ebiten.SetFullscreen(true)
if runtime.GOOS == "js" {
if ebiten.IsKeyPressed(ebiten.KeyF) || len(inpututil.AppendJustPressedTouchIDs(nil)) > 0 {
ebiten.SetFullscreen(true)
}
}
if runtime.GOOS != "js" && ebiten.IsKeyPressed(ebiten.KeyQ) {
return regularTermination
@ -105,7 +108,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
fw, fh := ebiten.ScreenSizeInFullscreen()
msg := "This is an example of the finest fullscreen.\n"
if runtime.GOOS == "js" {
msg += "Press F to enter fullscreen (again).\n"
msg += "Press F or touch the screen to enter fullscreen (again).\n"
} else {
msg += "Press Q to quit.\n"
}