[英]SpriteKit SKView no longer transitions between scenes in iOS 9
We have a code base that was written and released in 2013, but in iOS 9 the app no longer transitions visibly between SKScene
s when the presentScene:transition:
message is sent to our SKView
.我们有一个代码库是在 2013 年编写和发布的,但是在 iOS 9 中,当
presentScene:transition:
消息发送到我们的SKView
时,应用程序不再在SKScene
之间明显转换。 The SKScene
receives the didMoveToView:
message but the scene itself never shows on screen. SKScene
收到didMoveToView:
消息,但场景本身从未显示在屏幕上。
Here's what we tried:这是我们尝试过的:
Metal
via the Info.plist
Info.plist
禁用Metal
[SKTransition transitionWithCIFilter:duration:]
instead of the predefined animations[SKTransition transitionWithCIFilter:duration:]
而不是预定义的动画zPosition
zPosition
UIView
animations (this made our SKNode
s disappear)UIView
动画(这使我们的SKNode
消失了)pausesOutgoingScene
to YES
on the SKTransition
SKTransition
上明确设置pausesOutgoingScene
为YES
None of the above attempts fixed the issue.上述尝试均未解决该问题。 Note that everything transitions properly in iOS 8
请注意,一切都在 iOS 8 中正确转换
Here is some sample code that doesn't work:这是一些不起作用的示例代码:
-(BOOL)presentTitle {
if (!titleSceneLoaded) {
return NO;
}
[skView presentScene:titleScene transition:[SKTransition fadeWithDuration:1.0]];
return YES;
}
Changing it to this makes it work again (without the transitions):将其更改为此使其再次工作(没有转换):
-(BOOL)presentTitle {
if (!titleSceneLoaded) {
return NO;
}
[skView presentScene:titleScene];
return YES;
}
Any suggestions on how to locate/fix/workaround the bug?关于如何定位/修复/解决错误的任何建议?
There is a bug in iOS9 with presenting a scene with a transition in a subview. iOS9中存在一个错误,它在子视图中显示一个带有转换的场景。
I had the same issue and in my controller I was able to fix the issue by changing the following code in viewWillLayoutSubviews from this: 我有同样的问题,在我的控制器中,我能够通过更改viewWillLayoutSubviews中的以下代码来解决此问题:
[self.subview presentScene:self.scene];
[self.view addSubview:self.subview];
to this: 对此:
[((SKView *)self.view) presentScene:self.scene];
Another workaround if the scene has to remain in a subview approach is to use presentScene without the transition, which does work. 如果场景必须保持在子视图方法中,另一种解决方法是使用presentScene而不进行转换,这确实有效。
We were unable to get SKTransition
to work. 我们无法让
SKTransition
工作。 We talked to the developer support team, posted on the developer forums, and tried everything posted here. 我们与在开发人员论坛上发布的开发人员支持团队进行了交谈,并尝试了在此发布的所有内容。
It is SpriteKit bug exclusive to iOS 9. If anyone else runs into this bug on iOS 9, we switched to custom transitions utilizing UIView animateWithDuration:animations:completion:
. 它是iOS 9独有的SpriteKit bug。如果其他人在iOS 9上遇到这个bug,我们使用
UIView animateWithDuration:animations:completion:
切换到自定义转换UIView animateWithDuration:animations:completion:
。
It is a bit late but my own wrestling with what seems to be this bug may be worth exploring.有点晚了,但我自己与这个错误的斗争可能值得探索。
As I found out, I had a UIViewController floating around without having being fully deallocated, which had an SKView on it.正如我发现的那样,我有一个 UIViewController 在没有被完全释放的情况下四处漂浮,上面有一个 SKView。
The only side-effect from that SKView still being somewhat live was the presentScene(transition)
not working, as you have experienced. SKView 仍然存在的唯一副作用是
presentScene(transition)
不起作用,正如您所经历的那样。
It will work if you drag and drop the SKView in the storyboard instead of creating it manually .如果您将 SKView 拖放到 storyboard而不是手动创建它,它将起作用。
Then in the ViewController, create an outlet:然后在 ViewController 中,创建一个插座:
@IBOutlet var skView: SKView!
Then present the scene as:然后将场景呈现为:
homeScene = HomeScene(size: self.view.frame.size)
homeScene.scaleMode = .aspectFill
homeScene.backgroundColor = .clear
skView.presentScene(homeScene)
And from this SKScene, you can simply use the navigation with the transition as:从这个 SKScene 中,您可以简单地使用带有过渡的导航:
let gameScene = GameScene(size: self.size)
self.view?.presentScene(gameScene, transition: SKTransition.doorsOpenHorizontal(withDuration: 1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.