SceneKit:通过像SpriteKit中那样直接设置velocity属性来移动SCNNode?

时间:2017-01-29 00:46:53

标签: ios scenekit scnnode scnscene

在SpriteKit中,可以通过直接设置velocity属性来移动节点。

然而,这似乎不适用于SceneKit。设置velocity - 在游戏循环回调和游戏循环函数之外 - 似乎都没有效果。

来自其中一位Apple SceneKit工程师的

This answer建议只能在updateAtTime等游戏循环回调期间访问velocity属性。

显然,velocity属性存在限制。

使用SCNNodes无法直接控制属性吗?

1 个答案:

答案 0 :(得分:1)

正如@Confused所指出的,文档显示可以直接设置def main(): try: random = int(input('Enter an exact multiple of 19 that is greater than 200:')) except ValueError: print("Not a number") return number = random % 19 #if number==0 it's divisible by 19 if random <= 200: #checks to see if the number is less than 200 if number == 0: #if the num is divisible by 19 but less than 200 print("Enter an exact multiple of 19 that is greater than 200. No, {0} is a multiple of 19 but it is not greater than 200".format(random)) else: #if the num is not divisible by 19 ant it's less than 200 print("Enter an exact multiple of 19 that is greater than 200. No, {0} is not over 200 and also is not a multiple of 19".format(random)) return if number != 0: #if the number is over 200 buy not divisible by 19 print("Enter an exact multiple of 19 that is greater than 200. No, {0} is over 200 but is not a multiple of 19".format(random)) return #every other possibility: divisible by 19 and over 200 print('Good input 19 divides into {0} exactly {1} times'.format(random, random/19)) main() https://developer.apple.com/reference/scenekit/scnphysicsbody/1514757-velocity

关键是使用动态体型,而不是运动型(显然不是静态体型)。