mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
mobile/ebitenmobileview: Allow to call update before start
This fixes an issue that Update on another thread returns error when SetGame is not called. As SetGame is permitted to be called later, Update should not return error.
This commit is contained in:
parent
1f56266027
commit
12d0f273ec
@ -22,23 +22,19 @@ package ebitenmobileview
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/internal/uidriver/mobile"
|
"github.com/hajimehoshi/ebiten/internal/uidriver/mobile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
chError <-chan error
|
chError <-chan error
|
||||||
running bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func update() error {
|
func update() error {
|
||||||
if chError == nil {
|
if chError == nil {
|
||||||
return errors.New("ebitenmobileview: chError must not be nil: Start is not called yet?")
|
// start is not called yet, but as update can be called from another thread, it is OK. Just ignore
|
||||||
}
|
// this.
|
||||||
if !running {
|
return nil
|
||||||
return errors.New("ebitenmobileview: start must be called ahead of update")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@ -52,7 +48,6 @@ func update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func start(f func(*ebiten.Image) error, width, height int, scale float64) {
|
func start(f func(*ebiten.Image) error, width, height int, scale float64) {
|
||||||
running = true
|
|
||||||
// The last argument 'title' is not used on mobile platforms, so just pass an empty string.
|
// The last argument 'title' is not used on mobile platforms, so just pass an empty string.
|
||||||
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, "")
|
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, "")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user