mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Introduce mobile module
This commit is contained in:
parent
b1afe6aeb2
commit
dd9ab5e45a
36
mobile/run.go
Normal file
36
mobile/run.go
Normal file
@ -0,0 +1,36 @@
|
||||
package mobile
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
var chError <-chan error
|
||||
|
||||
// Start starts the game and returns immediately.
|
||||
//
|
||||
// Different from ebiten.Run, this invokes only the game loop and not the main (UI) loop.
|
||||
func Start(f func(*ebiten.Image) error, width, height, scale int, title string) {
|
||||
chError = ebiten.RunWithoutMainLoop(f, width, height, scale, title)
|
||||
return
|
||||
}
|
||||
|
||||
func LastErrorString() string {
|
||||
select {
|
||||
case err := <-chError:
|
||||
return err.Error()
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func SetScreenSize(width, height int) {
|
||||
// TODO: Implement this
|
||||
}
|
||||
|
||||
func SetScreenScale(scale int) {
|
||||
// TODO: Implement this
|
||||
}
|
||||
|
||||
func Render() {
|
||||
// TODO: Implement this
|
||||
}
|
17
run.go
17
run.go
@ -63,6 +63,23 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
||||
return <-ch
|
||||
}
|
||||
|
||||
// RunWithoutMainLoop runs the game, but don't call the loop on the main (UI) thread.
|
||||
// Different from Run, this function returns immediately.
|
||||
//
|
||||
// Typically, Ebiten users don't have to call this directly.
|
||||
// Instead, functions in github.com/hajimehoshi/ebiten/mobile module call this.
|
||||
func RunWithoutMainLoop(f func(*Image) error, width, height, scale int, title string) <-chan error {
|
||||
ch := make(chan error)
|
||||
go func() {
|
||||
g := newGraphicsContext(f)
|
||||
if err := loop.Run(g, width, height, scale, title, FPS); err != nil {
|
||||
ch <- err
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetScreenSize changes the (logical) size of the screen.
|
||||
// This doesn't affect the current scale of the screen.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user