How to create joints in Sprite Kit (Xcode)?

瘦欲@ 提交于 2019-12-22 00:05:21

问题


I don't understand how to create a joint to connect two bodies in SpriteKit. Thanks for help.


回答1:


The principle is the same for all joint types. First, create a joint connecting two bodies with some additional parameters (refer to the Sprite Kit Framework reference for details). Then add the newly created joint to the physics world:

CGPoint anchor = CGPointMake(100, 100);
SKPhysicsJointFixed* fixedJoint = [SKPhysicsJointFixed jointWithBodyA:aBody 
                                                                bodyB:otherBody
                                                               anchor:anchor];
[self.scene.physicsWorld addJoint:fixedJoint];

Now smoke it!



来源:https://stackoverflow.com/questions/18931353/how-to-create-joints-in-sprite-kit-xcode

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