mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gopherjs/gopherwasm/js"
|
"github.com/gopherjs/gopherwasm/js"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func IsGopherJS() bool {
|
||||||
|
return runtime.GOOS != "js"
|
||||||
|
}
|
||||||
|
|
||||||
func IsBrowser() bool {
|
func IsBrowser() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
|
func IsGopherJS() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func IsBrowser() bool {
|
func IsBrowser() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
6
run.go
6
run.go
@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = __EBITEN_REQUIRES_GO_VERSION_1_11_OR_LATER__
|
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 {
|
func run(width, height int, scale float64, title string, g *graphicsContext, mainloop bool) error {
|
||||||
atomic.StoreInt32(&isRunning, 1)
|
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.Run(width, height, scale, title, g, mainloop); err != nil {
|
||||||
if err == ui.RegularTermination {
|
if err == ui.RegularTermination {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user