Reputation: 505
Having some trouble figuring out what i need to add to the below code in order to switch scenes when a node is touched. What do i need to replace the '....' with in order to have the code below it 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)
}
}
Upvotes: 0
Views: 429
Reputation: 71852
You can use this code :
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for 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)
}
}
}
Upvotes: 4