ios - how to transition scenes with swift in spritekit -
having trouble figuring out need add below code in order switch scenes when node touched. need replace '....' in order have code below run.
override func touchesbegan(touches: set<nsobject>, withevent event: uievent) { .... if touchednode.name == "game button" { let transition = sktransition.revealwithdirection(sktransitiondirection.down, duration: 1.0) let scene = file(size: self.scene.size) scene.scalemode = skscenescalemode.aspectfill self.scene.view.presentscene(scene, transition: transition) } }
you can use code :
override func touchesbegan(touches: set<nsobject>, withevent event: uievent) { /* called when touch begins */ touch in (touches as! set<uitouch>) { let location = touch.locationinnode(self) if self.nodeatpoint(location) == self.playbutton { let reveal = sktransition.fliphorizontalwithduration(0.5) let letsplay = playscene(size: self.size) self.view?.presentscene(letsplay, transition: reveal) } } }
Comments
Post a Comment