[英]how to transition scenes with swift in spritekit
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)
}
}
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)
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.