我正在尝试使用NSNotificationCenter在两个NSNotificationCenter之间进行转换,但由于某种原因,crossFadeWithDuration在使用NSNotificationCenter的NSNotificationCenter时不能正常工作。
我的意思是,在新的SKScene开始融合之前,当前的SKScene将开始褪色为黑色,有点像常规的fadeWithDuration方法。
这是我的密码:
在我的ViewController中,我在我的viewDidLoad中发布了以下内容:
let crossFade = SKTransition.crossFadeWithDuration(5.0)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "bubblePop:", name:"openBubblePop", object: nil)这在我的SKScene中被称为:
func loadGame(sender: String) {
NSNotificationCenter.defaultCenter().postNotificationName("openBubblePop", object: self)
}这就是它在我的ViewController中运行的块:
func bubblePop(_:NSNotificationCenter) {
skView.presentScene(BubblePop(size: skView.bounds.size), transition: crossFade)
}我已经尝试通过一个presentScene调用相同的UIButton行,并且转换工作与预期的一样。有人知道为什么会这样吗?
更新我已经就这个问题向苹果提交了一份错误报告。CrossFadeWithDuration只有在iOS 8上运行时才能正常工作,并且在iOS 7和9中运行不正确。
发布于 2015-11-18 02:27:54
为什么要使用NSNotificationCenter呢?来自您的SKScene电话:
self.view?.presentScene(BubblePop(size: (self.view?.bounds.size)!), transition: SKTransition.crossFadeWithDuration(5.0))https://stackoverflow.com/questions/33770340
复制相似问题