如何在 Sprite Kit (Xcode) 中创建关节? [英] How to create joints in Sprite Kit (Xcode)?
本文介绍了如何在 Sprite Kit (Xcode) 中创建关节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白如何在 SpriteKit 中创建连接两个物体的关节.感谢您的帮助.
I don't understand how to create a joint to connect two bodies in SpriteKit. Thanks for help.
推荐答案
所有关节类型的原理都是一样的.首先,使用一些附加参数创建连接两个主体的关节(请参阅 Sprite Kit 框架参考 了解详情).然后将新创建的关节添加到物理世界:
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];
现在抽它!
这篇关于如何在 Sprite Kit (Xcode) 中创建关节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文