ios - Transition to GameScene from GameOverScene -
i'm trying transition gamescene gameoverscene. have following touchesbegan function when press 'replay game' button not transition.
override func touchesbegan(touches: set<uitouch>, withevent event: uievent?) { let touch = touches.first! uitouch let touchlocation = touch.locationinnode(self) let touchednode = self.nodeatpoint(touchlocation) if let name = touchednode.name { if name == "replay"{ print("touching replay") let reveal : sktransition = sktransition.fliphorizontalwithduration(0.5) let scene = gamescene(size: self.size) scene.scalemode = .aspectfill self.view?.presentscene(scene, transition: reveal) } } }
i have following used create replay node:
let replaymessage = "replay game" var replaybutton = sklabelnode(fontnamed: "chalkduster") replaybutton.text = replaymessage replaybutton.fontcolor = skcolor.blackcolor() replaybutton.position = cgpointmake(self.size.width/2, 50) replaybutton.name = "replay" self.addchild(replaybutton)
i following output:
touching replay 2016-02-03 01:11:08.102 test [1010:196002] cuicatalog: invalid request: requesting subtype without specifying idiom
hi , try :
override func touchesbegan(touches: set<uitouch>, withevent event: uievent?) { let touch = touches.first! uitouch let touchlocation = touch.locationinnode(self) let touchednode = self.nodeatpoint(touchlocation) if let name = touchednode.name { if name == "replay"{ let transition = sktransition.fadewithcolor(uicolor.whitecolor(), duration:1.0) let gameover = mainscene(size: scene!.size) gameover.scalemode = scalemode view!.presentscene(gameover, transition: transition) print("game over!") } } }
Comments
Post a Comment