example/sprite: move to events
Change-Id: I5f5b2aee9edebc7b50ee98e23da5f0fa7e06112d
Reviewed-on: https://go-review.googlesource.com/12335
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/example/sprite/main.go b/example/sprite/main.go
index a9f2fe8..b5c06f9 100644
--- a/example/sprite/main.go
+++ b/example/sprite/main.go
@@ -37,6 +37,7 @@
"golang.org/x/mobile/app"
"golang.org/x/mobile/asset"
"golang.org/x/mobile/event/config"
+ "golang.org/x/mobile/event/paint"
"golang.org/x/mobile/exp/app/debug"
"golang.org/x/mobile/exp/f32"
"golang.org/x/mobile/exp/sprite"
@@ -52,12 +53,21 @@
)
func main() {
- app.Run(app.Callbacks{
- Draw: onDraw,
+ app.Main(func(a app.App) {
+ var c config.Event
+ for e := range a.Events() {
+ switch e := app.Filter(e).(type) {
+ case config.Event:
+ c = e
+ case paint.Event:
+ onPaint(c)
+ a.EndPaint()
+ }
+ }
})
}
-func onDraw(c config.Event) {
+func onPaint(c config.Event) {
if scene == nil {
loadScene()
}