mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02: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 (
|
||||
"errors"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/internal/uidriver/mobile"
|
||||
)
|
||||
|
||||
var (
|
||||
chError <-chan error
|
||||
running bool
|
||||
)
|
||||
|
||||
func update() error {
|
||||
if chError == nil {
|
||||
return errors.New("ebitenmobileview: chError must not be nil: Start is not called yet?")
|
||||
}
|
||||
if !running {
|
||||
return errors.New("ebitenmobileview: start must be called ahead of update")
|
||||
// start is not called yet, but as update can be called from another thread, it is OK. Just ignore
|
||||
// this.
|
||||
return nil
|
||||
}
|
||||
|
||||
select {
|
||||
@ -52,7 +48,6 @@ func update() error {
|
||||
}
|
||||
|
||||
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.
|
||||
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, "")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user