如果我在没有SKAction的情况下直接修改SKSpriteNode的位置和旋转,SpriteKit是否会应用物理?

问题描述:

例如,如果我想做自己的自定义动画并按照 x + = 10 以编程方式每帧移动SKSpriteNode,Sprite Kit是否仍会正确应用物理或必须我总是使用SKAction?

For example if I want to do my own custom animation and move an SKSpriteNode every frame programmatically by x += 10, will Sprite Kit still apply physics correctly or must I always use SKAction?

无论你是怎么做什么,都可以用物理机构手动移动节点。但无论如何不推荐它,因为它会对物理模拟产生不利影响。节点(视图)可能与身体的位置不同步1帧,并且您可能将身体移动到物理引擎将强制解决的碰撞中,从而导致跳跃,抖动,爆炸速度或跳过碰撞。

Manually moving a node with a physics body is possible regardless of how or when you do it. But in any case it's not recommended since it can adversely affect the physics simulation. The node (view) could be out of sync with the position of the body for 1 frame, and you might move the body into a collision which the physics engine will forcibly resolve, causing jumps, jitter, exploding velocities or skipping collisions.

使用物理时,坚持通过力,冲动或直接改变体速来移动物理体。