SKAction.moveByX not setting physicsBody.velocity

后端 未结 1 792
时光说笑
时光说笑 2021-01-17 03:36

I\'m writing a SpriteKit game using Swift, and am using the following code to move my sprite - however, it doesn\'t seem to be updating velocity.dx:

func wal         


        
相关标签:
1条回答
  • 2021-01-17 04:18

    Actions and physics are largely separate mechanisms in SpriteKit. Generally, if you're using physics to move a body, you shouldn't use move actions on it. If you want to move a body that's already using physics, use physics to move it -- apply a force or impulse, or set its velocity directly.

    Conversely, when you use actions to move a body, or set its position directly, those changes don't go through the physics engine. If you want to find the speed of a node during a move action, you'll have to calculate it yourself by observing the change in its position between frames.

    0 讨论(0)
提交回复
热议问题