mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 03:58:55 +01:00
mobile: Throw error when update is called without starting (#311)
This commit is contained in:
parent
3b9e6c2708
commit
fd71c86e20
@ -23,15 +23,22 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var chError <-chan error
|
var (
|
||||||
|
chError <-chan error
|
||||||
|
running bool
|
||||||
|
)
|
||||||
|
|
||||||
func update() error {
|
func update() error {
|
||||||
if chError == nil {
|
if chError == nil {
|
||||||
return errors.New("mobile: chError must not be nil: Start is not called yet?")
|
return errors.New("mobile: chError must not be nil: Start is not called yet?")
|
||||||
}
|
}
|
||||||
|
if !running {
|
||||||
|
return errors.New("mobile: start must be called ahead of update")
|
||||||
|
}
|
||||||
return ui.Render(chError)
|
return ui.Render(chError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func start(f func(*ebiten.Image) error, width, height int, scale float64, title string) {
|
func start(f func(*ebiten.Image) error, width, height int, scale float64, title string) {
|
||||||
|
running = true
|
||||||
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, title)
|
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, title)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user