gpt4 book ai didi

ios - SKTransition crossFadeWithDuration 在 Swift 中无法正常工作

转载 作者:搜寻专家 更新时间:2023-11-01 05:38:36 24 4
gpt4 key购买 nike

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

我所说的“不正确”是指当前 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 中运行的 block :

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))

关于ios - SKTransition crossFadeWithDuration 在 Swift 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33770340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com