【发布时间】:2014-07-29 12:01:16
【问题描述】:
在 Objective-C 中,使用 Sprite-Kit,我会成功在 Objective-C 中使用类似于以下代码的代码来创建一个新场景
if ([touchedNode.name isEqual: @"Game Button"]) {
SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:1.0];
GameScene *newGameScene = [[GameScene alloc] initWithSize: self.size];
// Optionally, insert code to configure the new scene.
newGameScene.scaleMode = SKSceneScaleModeAspectFill;
[self.scene.view presentScene: newGameScene transition: reveal];
}
在尝试将我的简单游戏移植到 Swift 时,到目前为止我已经完成了这项工作......
for touch: AnyObject in touches {
let touchedNode = nodeAtPoint(touch.locationInNode(self))
println("Node touched: " + touchedNode.name);
let touchedNodeName:String = touchedNode.name
switch touchedNodeName {
case "Game Button":
println("Put code here to launch the game scene")
default:
println("No routine established for this")
}
但我不知道要编写什么代码才能真正过渡到另一个场景。 问题:
- 谁能提供一个在 Swift 中使用 SKTransition 的示例?
谢谢
【问题讨论】:
-
2. Swift 实际上使使用多个文件变得更容易,因为它会自动导入模块中的所有文件。没有任何理由不遵循与 Objective-C 相同的模式
标签: sprite-kit swift transitions ios8 xcode6