swift - 如何获得当前正在进行的 SCNAction 的剩余持续时间?

标签 swift scenekit duration

NodeA 有一个 SCNAction 运行,持续时间为 10 秒。 假设 4 秒过去了。 如何获得正在进行的 SCNAction 的剩余持续时间(在本例中为 6 秒)?

我计划使用剩余的持续时间来动态创建另一个 SCNAction,总计 10 秒。

所以 NodeA Action 时长 + NodeB Action 时长 = 10。

最佳答案

如果你想操作elapsedTime,你应该使用SCNAction.customAction,例如:

let runningAction = SCNAction.customAction(duration: 10) { (node, elapsedTime) -> () in 
  // do stuff here with elapsedTime
  print(elapsedTime)
}

When the action executes, SceneKit calls the block repeatedly until the action’s duration expires. For each call, SceneKit computes the elapsed time and passes it to the block

文档 here

关于swift - 如何获得当前正在进行的 SCNAction 的剩余持续时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48245878/

相关文章:

swift - 如何使用 lookAtConstraint 获取节点的方向

PHP:向日期添加秒数

android - 在 Android 中获取音频文件持续时间的最佳方法是什么?

ios - SceneKit 中声明的 func hitTest 导致 Playground 崩溃

ios - SceneKit unproject 一个点给出了奇怪的结果

ios - 如何以分钟为单位获取歌曲长度?

json - 在 Swift 中使类默认符合 Codable

ios - 通过在 Collection View 单元格内按下按钮来实例化 Storyboard

Swift avspeechsynthesizer 不同的语言

ios - 如何将 UIViewController 传递给 Swift 中的另一个类?