如何检查 SCNAction 是否已在 Swift 内完成 3
How to check if SCNAction has completed in Swift 3
这里我有一组动画作用于名为 testNode
的 SCNSphere
//run this during the duration of the two animations below
earthNode.runAction(SCNAction.rotateBy(x: 0, y: 5, z: 5, duration: 4))
//run this action right away
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: -5, duration: 2))
//RUN THIS ACTION AFTER ACTION ABOVE IS COMPLETED
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: 5, duration: 2))
我试图阻止最后两个动画同时发生。我如何检查第二个动画是否完成,然后 运行 列出最后一个动画。我也很感激检查一组动画是否同时 运行ning 完成的解释。
您可以像使用 SKActions 一样制作一个序列:
/* Actions */
let moveUp = SKAction.moveBy(x: 0, y: 100, duration: 1.0)
let zoom = SKAction.scale(to: 2.0, duration: 0.25)
let sequence = SKAction.sequence([moveUp, zoom])
let node = SKNode()
node.run(sequence)
有 SCNAction.group() 和 SCNAction.sequence():
class func group([SCNAction])
创建一个并行运行一组操作的操作。
class func sequence([SCNAction])
创建一个按顺序运行一组动作的动作(我猜这就是你需要的)。
/* Action with sequence of actions */
let move = SCNAction.sequence([moveUp, moveDown, moveLeft, moveRight]) // will be executed one by one
let rotate = SCNAction.rotateBy(x: 0, y: .pi, z: 0, duration: 2)
/* Group actions */
let group = SCNAction.group([rotate, move])
node.runAction(group, completionHandler:nil)
这里我有一组动画作用于名为 testNode
SCNSphere
//run this during the duration of the two animations below
earthNode.runAction(SCNAction.rotateBy(x: 0, y: 5, z: 5, duration: 4))
//run this action right away
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: -5, duration: 2))
//RUN THIS ACTION AFTER ACTION ABOVE IS COMPLETED
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: 5, duration: 2))
我试图阻止最后两个动画同时发生。我如何检查第二个动画是否完成,然后 运行 列出最后一个动画。我也很感激检查一组动画是否同时 运行ning 完成的解释。
您可以像使用 SKActions 一样制作一个序列:
/* Actions */
let moveUp = SKAction.moveBy(x: 0, y: 100, duration: 1.0)
let zoom = SKAction.scale(to: 2.0, duration: 0.25)
let sequence = SKAction.sequence([moveUp, zoom])
let node = SKNode()
node.run(sequence)
有 SCNAction.group() 和 SCNAction.sequence():
class func group([SCNAction])
创建一个并行运行一组操作的操作。
class func sequence([SCNAction])
创建一个按顺序运行一组动作的动作(我猜这就是你需要的)。
/* Action with sequence of actions */
let move = SCNAction.sequence([moveUp, moveDown, moveLeft, moveRight]) // will be executed one by one
let rotate = SCNAction.rotateBy(x: 0, y: .pi, z: 0, duration: 2)
/* Group actions */
let group = SCNAction.group([rotate, move])
node.runAction(group, completionHandler:nil)