Change position of a SKSpriteNode that has a physicsBody

前端 未结 7 2248
遇见更好的自我
遇见更好的自我 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 22:10

    Seems similar to SKSPriteNode position changes to 0,0 for no reason

    As stated in answer and comments of this question, it seems you must either set the position before setting the physicsBody and/or set the physicsBody after adding the node to your scene.

    I've had this problem in several scenarios and I haven't found out what exactly causes it to fail sometimes.

提交回复
热议问题