SCNAction.wait 不在 swift 游乐场工作

SCNAction.wait not working in swift playgrounds

在我的代码中,我有一个序列,其中我告诉 swift 在我继续另一个函数之前等待序列完成,但是它似乎跳过这个并继续前进

let earthSequence = SCNAction.sequence([SCNAction.wait(duration: 10),rollInGroup,rollOutGroup,earthNormalRotation])
defaultEarthNode.runAction(earthSequence)

nextFunction()

结果是无需等待 10 秒就直接进入下一个功能

这是因为 nextFunction() 是在您开始操作后立即调用的,它不会等待它完成。 runAction 有一个 completionHandler 可以用来知道序列何时完成。

defaultEarthNode.runAction(earthSequence, completionHandler: {
    nextFunction()
})