Change position of a SKSpriteNode that has a physicsBody

前端 未结 7 2252
遇见更好的自我
遇见更好的自我 2021-02-13 22:02

I can\'t change the position of a SKSpriteNode by changing

self.position = newPosition;

It doesn\'t work anymore if it has a physicsBody.

相关标签:
7条回答
  • 2021-02-13 22:36

    I had a problem like this where I tried to update position inside didBeginContact:, but it was not having any effect, I think because the physics simulation immediately clobbers the value.

    My solution was to cache the new position in a property on my scene and then update the position of the node next time update: was called on my scene.

    [SKAction moveTo:newPosition duration:0.0] worked for me, too, and there was no popping. I haven't decided yet which is more elegant.

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