SCNAction 未触发
SCNAction not firing
我的 SCNAction
不工作,即使编译器到达那里。这是我创建 SCNAction
:
的代码
println("log 1") //to check the program gets there
let moveInit1: SCNAction = SCNAction.moveTo(SCNVector3Make(0, -3, 0), duration: 1)
moveInit1.timingMode = SCNActionTimingMode.EaseOut
cube.runAction(moveInit1)
println("log 2") //check again
输出是 log 1
和 log 2
但没有动画发生...
有人知道为什么吗?
备注
我在另一种方法中有完全相同的代码,它确实有效。
我不知道为什么你的代码不起作用,但这段代码对我有用。
var node = SCNNode.new()
node.geometry = SCNSphere(radius: 1)
var action = SCNAction.moveTo(SCNVector3Make(0, 3, 0), duration: 1)
action.timingMode = SCNActionTimingMode.EaseOut
node.runAction(action)
好的,我找到问题了。当我全局创建我的节点时(因此它可用于多种方法)我将它设置为 let
。我在 setup()
方法中用 var
重新定义了节点,Xcode 没有抱怨,显然我有两个同名的不同节点。
第一个节点(常量节点)没有包含我在 setup()
.
中所做的所有配置
这就是导致问题的原因,它现在运行完美:)
我的 SCNAction
不工作,即使编译器到达那里。这是我创建 SCNAction
:
println("log 1") //to check the program gets there
let moveInit1: SCNAction = SCNAction.moveTo(SCNVector3Make(0, -3, 0), duration: 1)
moveInit1.timingMode = SCNActionTimingMode.EaseOut
cube.runAction(moveInit1)
println("log 2") //check again
输出是 log 1
和 log 2
但没有动画发生...
有人知道为什么吗?
备注
我在另一种方法中有完全相同的代码,它确实有效。
我不知道为什么你的代码不起作用,但这段代码对我有用。
var node = SCNNode.new()
node.geometry = SCNSphere(radius: 1)
var action = SCNAction.moveTo(SCNVector3Make(0, 3, 0), duration: 1)
action.timingMode = SCNActionTimingMode.EaseOut
node.runAction(action)
好的,我找到问题了。当我全局创建我的节点时(因此它可用于多种方法)我将它设置为 let
。我在 setup()
方法中用 var
重新定义了节点,Xcode 没有抱怨,显然我有两个同名的不同节点。
第一个节点(常量节点)没有包含我在 setup()
.
这就是导致问题的原因,它现在运行完美:)