uidriver/mobile: Refactoring: Give a default outside size

This commit is contained in:
Hajime Hoshi 2020-02-11 22:58:59 +09:00
parent d0fce2a2db
commit aef4b4ba53
2 changed files with 6 additions and 3 deletions

View File

@ -47,6 +47,11 @@ var (
theUI = &UserInterface{ theUI = &UserInterface{
foreground: true, foreground: true,
// Give a default outside size so that the game can start without initializing them.
outsideWidth: 640,
outsideHeight: 480,
sizeChanged: true,
} }
) )

View File

@ -58,6 +58,7 @@ func SetGame(game ebiten.Game) {
panic("ebitenmobileview: SetGame cannot be called twice or more") panic("ebitenmobileview: SetGame cannot be called twice or more")
} }
theState.game = game theState.game = game
theState.errorCh = ebiten.RunGameWithoutMainLoop(theState.game)
} }
func Layout(viewWidth, viewHeight float64) { func Layout(viewWidth, viewHeight float64) {
@ -65,9 +66,6 @@ func Layout(viewWidth, viewHeight float64) {
defer theState.m.Unlock() defer theState.m.Unlock()
mobile.Get().SetOutsideSize(viewWidth, viewHeight) mobile.Get().SetOutsideSize(viewWidth, viewHeight)
if !theState.isRunning() {
theState.errorCh = ebiten.RunGameWithoutMainLoop(theState.game)
}
} }
func Update() error { func Update() error {