在 SpriteKit 中,当场景完成转换时是否有回调?
它看起来不像 SKView presentScene
函数有一个回调。
另一种方法是让场景在场景进入 View 后手动通知调用者,但希望有一种更简洁的方法,带有原生回调。
最佳答案
presentScene
在场景完成转换时没有已知的回调,而是使用 Notification
或在您的传出场景上创建您自己的某种委托(delegate) func willMove(from:view)
实现想要的效果
func willMove(from view:SKView)
{
NotificationCenter.default.post(name: "TRANSITIONCOMPLETE", object: nil)
//or create a delegate using protocols, assign the delegate, and call it
delegate?.finishedTransition()
}
请注意,您必须使用 outgoingScenes willMove(from:view)
,这是过渡期间发生的最后一件事。 incomingScene 上的 didMove(to:view)
是过渡的开始
关于ios - SpriteKit : callback when scene is done presenting?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45113841/