func (t *TestScene) OnMainMenuCallback(_ cc.Node) { cc.Log("begin OnMainMenuCallback") scene := cc.NewScene() layer := t.controller.Clone().Layer scene.AddChild(layer) //TODO transition progress cc.Director().RunScene(scene) }
func NewHelloWorldScene() cc.Scene { scene := cc.NewScene() scene.SetOnEnter(func() { scene.OnEnterSuper() layer := NewHelloWorldLayer() scene.AddChild(layer) }) return scene }
func main() { cc.Game.SetOnStart(func() { cc.Log("starts from main.go", "begin tests") cc.View().AdjustViewPort(true) cc.View().SetDesignResolutionSize(800, 450, cc.SHOW_ALL) cc.View().ResizeWithBrowserSize(true) cc.LoaderScene().Preload(resources, func() { scene := cc.NewScene() scene.AddChild(test.NewTestController(testNames, resources).Layer) cc.Director().RunScene(scene) }) }) cc.Game.Run() }
func NewTestScene(controller *TestController) *TestScene { testScene := &TestScene{ Scene: cc.NewScene(), controller: controller, } label := cc.NewLabelTTF("Main Menu", "Arial", 20) menuItem := cc.NewMenuItemLabelAllArgs(label, testScene.OnMainMenuCallback, testScene.Scene) menuItem.SetPosition(cc.NewPoint(cc.WinSize().Width()-50, 25)) menu := cc.NewMenu(menuItem) menu.SetPosition(cc.NewPoint(0, 0)) testScene.Scene.AddChildWithOrder(menu, 1) return testScene }