SKTransition crossFadeWithDuration 在 Swift 中未按预期工作

SKTransition crossFadeWithDuration not working as expected in Swift

我正在尝试使用 NSNotificationCenter 在两个 SKScenes 之间进行转换,但由于某些原因,当我从 SKScene 使用 NSNotificationCenter 时,crossFadeWithDuration 无法正常工作。

"not properly" 我的意思是在新的 SKScene 开始融入之前,当前的 SKScene 将开始淡化为黑色,有点像常规的 fadeWithDuration 方法。

这是我的代码:

在我的 ViewController 中,我 post 在我的 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)
}

我尝试通过 UIButton 调用相同的 presentScene 行,并且转换按预期工作。有人知道为什么会这样吗?

更新 我已就此问题向 Apple 提交了错误报告。 CrossFadeWithDuration 仅在 运行 在 iOS 8 时才能正常工作,而在 iOS 7 和 9.

中运行不正确

为什么要使用 NSNotificationCenter?来自您的 SKScene 电话:

self.view?.presentScene(BubblePop(size: (self.view?.bounds.size)!), transition: SKTransition.crossFadeWithDuration(5.0))