Exemplo n.º 1
0
func GetInstance() *Simra {
	peer.LogDebug("IN")
	if simra == nil {
		simra = &Simra{}
	}
	peer.LogDebug("OUT")
	return simra
}
Exemplo n.º 2
0
func GetInstance() *Gomo {
	peer.LogDebug("IN")
	if gomo == nil {
		gomo = &Gomo{}
	}
	peer.LogDebug("OUT")
	return gomo
}
Exemplo n.º 3
0
func (self *Simra) SetScene(driver Driver) {
	peer.LogDebug("IN")
	peer.GetGLPeer().Reset()
	peer.GetTouchPeer().RemoveAllTouchListener()

	self.driver = driver
	driver.Initialize()
	peer.LogDebug("OUT")
}
Exemplo n.º 4
0
func (self *Gomo) Initialize(onStart, onStop chan bool, updateCallback func()) {
	peer.LogDebug("IN")
	self.glPeer = peer.GetGLPeer()
	self.touchPeer = peer.GetTouchPeer()
	self.onStart = onStart
	self.onStop = onStop
	self.updateCallback = updateCallback
	peer.LogDebug("OUT")
}
Exemplo n.º 5
0
func main() {
	peer.LogDebug("[IN]")
	engine := simra.GetInstance()

	onStart := make(chan bool)
	onStop := make(chan bool)
	go eventHandle(onStart, onStop)
	engine.Start(onStart, onStop)
	peer.LogDebug("[OUT]")
}
Exemplo n.º 6
0
func (self *Stage1) Initialize() {
	peer.LogDebug("[IN]")

	peer.SetDesiredScreenSize(1080/2, 1920/2)
	peer.GetTouchPeer().AddTouchListener(self)

	// initialize sprites
	self.initSprite()

	peer.LogDebug("[OUT]")
}
Exemplo n.º 7
0
func (self *Title) Initialize() {
	peer.LogDebug("[IN]")

	peer.SetDesiredScreenSize(960, 540)
	peer.GetTouchPeer().AddTouchListener(self)

	// initialize sprites
	self.initialize()

	peer.LogDebug("[OUT]")
}
Exemplo n.º 8
0
func (self *Gomo) Start() {
	peer.LogDebug("IN")
	app.Main(func(a app.App) {
		for e := range a.Events() {

			switch e := a.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:

					// initialize gl peer
					glctx, _ := e.DrawContext.(gl.Context)
					self.glPeer.Initialize(glctx)

					// time to set first scene
					self.onStart <- true
					a.Send(paint.Event{})
				case lifecycle.CrossOff:

					// time to stop application
					self.onStop <- true

					// finalize gl peer
					self.glPeer.Finalize()
				}
			case size.Event:
				peer.SetScreenSize(e)
			case paint.Event:
				if e.External {
					continue
				}

				// update notify for simra
				self.updateCallback()

				// update notify for gl peer
				self.glPeer.Update()

				a.Publish()
				a.Send(paint.Event{})
			case touch.Event:
				switch e.Type {
				case touch.TypeBegin:
					self.touchPeer.OnTouchBegin(e.X, e.Y)
				case touch.TypeMove:
					self.touchPeer.OnTouchMove(e.X, e.Y)
				case touch.TypeEnd:
					self.touchPeer.OnTouchEnd(e.X, e.Y)
				}
			}
		}
	})
	peer.LogDebug("OUT")
}
Exemplo n.º 9
0
func eventHandle(onStart, onStop chan bool) {
	for {
		select {
		case <-onStart:
			peer.LogDebug("receive chan. onStart")
			engine := simra.GetInstance()
			// TODO: this will be called on rotation.
			// to keep state on rotation, SetScene must not call
			// every onStart.
			engine.SetScene(&scene.Title{})
		case <-onStop:
			peer.LogDebug("receive chan. onStop")
		}
	}
}
Exemplo n.º 10
0
func (self *Simra) Start(onStart, onStop chan bool) {
	peer.LogDebug("IN")
	gomo.GetInstance().Initialize(onStart, onStop, self.onUpdate)
	gomo.GetInstance().Start()
	peer.LogDebug("OUT")
}
Exemplo n.º 11
0
func (self *Simra) onStopped() {
	peer.LogDebug("IN")
	self.driver = nil
	peer.GetGLPeer().Finalize()
	peer.LogDebug("OUT")
}