作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Stackoverflow 新手,如果我发布错误,非常抱歉!谢谢
我的应用程序是一个有时间限制的迷宫游戏,一旦时间达到 0,游戏就会结束并进入游戏结束屏幕(单独的 swift 文件),这由一个“重播”按钮组成,按下该按钮时仅显示gamescene.sks 文件而不是 gamescene.swift 文件(因此所有功能都不起作用)。有没有办法同时显示两者?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location) //1
if node.name == "replay" { //2
let reveal : SKTransition = SKTransition.flipHorizontalWithDuration(1)
let scene = GameScene(size: self.size)
scene.scaleMode = .AspectFill
self.view?.presentScene(scene, transition: reveal)
let reveal2 : SKTransition = SKTransition.flipHorizontalWithDuration(1)
let sksScene = SKScene(fileNamed: "GameScene.sks")
sksScene!.scaleMode = .AspectFill
self.view?.presentScene(sksScene!, transition: reveal2)
}
}
}
最佳答案
您需要确保在加载 GameScene.sks 时使用您的 GameScene 子类
let skView = self.view as SKView!
let transition = SKTransition.flipHorizontalWithDuration(0.5)
let scene = GameScene(fileNamed:"GameScene") as GameScene!
scene.scaleMode = .AspectFill
skView.presentScene(scene, transition: transition)
您只需使用 presentScene
一次:]
关于swift - 当我单击 "Replay"按钮时,仅运行 GameScene.sks,而不运行 GameScene.swift...如何让两者同时玩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36889214/
我是一名优秀的程序员,十分优秀!