Пример #1
0
func (a *Application) handleLifecycle(e lifecycle.Event) {
	switch e.Crosses(lifecycle.StageVisible) {
	case lifecycle.CrossOn:
		a.visible = true
		a.onStart(e.DrawContext.(gl.Context))
	case lifecycle.CrossOff:
		a.visible = false
		a.onStop()
	}
}
Пример #2
0
func onLifecycleEvent(e *lifecycle.Event) {
	log.Println("onLifecycleEvent", e)
	crossAlive := e.Crosses(lifecycle.StageAlive)
	crossVisible := e.Crosses(lifecycle.StageVisible)
	crossFocused := e.Crosses(lifecycle.StageFocused)
	if crossAlive == lifecycle.CrossOn {
		log.Println("onCreate")
	}
	if crossVisible == lifecycle.CrossOn {
		log.Println("onStart")
	}
	if crossFocused == lifecycle.CrossOn {
		log.Println("onResume")
	} else if crossFocused == lifecycle.CrossOff {
		log.Println("onFreeze")
	}
	if crossVisible == lifecycle.CrossOff {
		log.Println("onStop")
	}
	if crossAlive == lifecycle.CrossOff {
		log.Println("onDestroy")
	}
}