mobile: Throw error when update is called without starting (#311)

This commit is contained in:
Hajime Hoshi 2017-06-04 22:37:43 +09:00
parent 3b9e6c2708
commit fd71c86e20

View File

@ -23,15 +23,22 @@ import (
"github.com/hajimehoshi/ebiten/internal/ui"
)
var chError <-chan error
var (
chError <-chan error
running bool
)
func update() error {
if chError == nil {
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)
}
func start(f func(*ebiten.Image) error, width, height int, scale float64, title string) {
running = true
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, title)
}