SpriteKit: How to create Basic Physics Joints

倾然丶 夕夏残阳落幕 提交于 2019-11-30 12:56:20

Thank you Smick.. After Comparing Smick's code with mine I found out the order of these two lines are causing the issue.

head.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:head.size];
head.position = CGPointMake(backBone.position.x, backBone.position.y-40);

When I set the position of the Sprite before Setting its physics body, everything started to work correctly.

head.position = CGPointMake(backBone.position.x, backBone.position.y-40);
head.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:head.size];

Now I have attached Smick's code also to the full code and attached the link down here. Enjoy.

https://dl.dropboxusercontent.com/u/62559842/PhysicsTest_Final_Working.zip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!