mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
ui: Bug fix: isRunning should never be 'false' even after Run on GopherJS
This commit is contained in:
parent
58cc5cb105
commit
55e9a861d0
@ -17,11 +17,16 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/gopherjs/gopherwasm/js"
|
||||
)
|
||||
|
||||
func IsGopherJS() bool {
|
||||
return runtime.GOOS != "js"
|
||||
}
|
||||
|
||||
func IsBrowser() bool {
|
||||
return true
|
||||
}
|
||||
|
@ -16,6 +16,10 @@
|
||||
|
||||
package web
|
||||
|
||||
func IsGopherJS() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func IsBrowser() bool {
|
||||
return false
|
||||
}
|
||||
|
6
run.go
6
run.go
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
"github.com/hajimehoshi/ebiten/internal/web"
|
||||
)
|
||||
|
||||
var _ = __EBITEN_REQUIRES_GO_VERSION_1_11_OR_LATER__
|
||||
@ -91,7 +92,10 @@ var theGraphicsContext atomic.Value
|
||||
|
||||
func run(width, height int, scale float64, title string, g *graphicsContext, mainloop bool) error {
|
||||
atomic.StoreInt32(&isRunning, 1)
|
||||
defer atomic.StoreInt32(&isRunning, 0)
|
||||
// On GopherJS, run returns immediately.
|
||||
if !web.IsGopherJS() {
|
||||
defer atomic.StoreInt32(&isRunning, 0)
|
||||
}
|
||||
if err := ui.Run(width, height, scale, title, g, mainloop); err != nil {
|
||||
if err == ui.RegularTermination {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user