【发布时间】:2016-02-18 03:53:57
【问题描述】:
编辑
我比较了在 iPhone (6+, 9.3 (13E5200d)) 上运行的结果,这是我的默认设置和 iOS 模拟器 (6+ 9.3 (13E5200d))。模拟器按预期工作。为什么两者之间存在差异?
我有一个看似简单的设置,我想在触摸时执行一系列动画。为此,我雇用了SCNAction。在每个动画之后,我想重新评估某些事情,所以我有一个在完成处理程序中调用的step 函数,而不是一个长的SCNAction.sequence()。问题是完成处理程序不会在任意数量的步骤之后被调用。
在这种情况下,这是一步。
let path = [
SCNAction.sequence([
SCNAction.moveBy(SCNVector3(2.7, 0, 0), duration: 0.25),
SCNAction.waitForDuration(1)
]),
SCNAction.sequence([
SCNAction.moveBy(SCNVector3(2.7, 0, 0), duration: 0.25),
SCNAction.waitForDuration(1)
]),
SCNAction.sequence([
SCNAction.moveBy(SCNVector3(2.7, 0, 0), duration: 0.25),
SCNAction.waitForDuration(1)
]),
]
let nodeGeometry = SCNBox(width: 2.7, height: 2.7, length: 2.7, chamferRadius: 0)
nodeGeometry.firstMaterial = SCNMaterial()
nodeGeometry.firstMaterial?.diffuse.contents = UIColor.redColor()
let node = SCNNode(geometry: nodeGeometry)
scene.rootNode.addChildNode(node)
func step (index: Int) {
print(index, "enter")
node.runAction(path[index]) {
print(index, "callback")
if ((index + 1) < path.count) {
step(index + 1)
}
}
}
step(0)
此代码产生以下序列
0 enter
0 callback
1 enter
我没有收到第二个回调。为什么?我如何知道SCNAction 何时完成执行?
【问题讨论】: