【问题标题】:How can I "pin" sprites to other sprites in Sprite Kit?如何将精灵“固定”到 Sprite Kit 中的其他精灵?
【发布时间】:2013-10-25 01:25:56
【问题描述】:

所以我有一个想在 Sprite Kit 中展示的木偶。木偶由一堆不同的身体部位组成,当然每个部位都是.png。

所以我的流程是:我有一个 Marionette 对象(SKNode 子类)。我将头部添加到此节点。现在,我将胸部添加到头部。它工作正常,但如果我添加物理,并使 2 个图像落到地上,它们会粘在一起直到胸部(低于头部)撞到地面。胸口停住,头不断下坠分离。我想要的是让身体部位粘在一起。

这是我用来将胸部连接到头部的代码,有什么想法可以实现吗?

self.chest = [SKSpriteNode spriteNodeWithImageNamed:@"chest_neck.png"];
self.chest.anchorPoint = CGPointMake(0.5, 0.0);
self.chest.position = CGPointMake(4, -135);
[self.head addChild:self.chest];
self.chest.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:20];
self.chest.physicsBody.mass = 1;
self.chest.physicsBody.dynamic = YES;

【问题讨论】:

    标签: ios physics sprite-kit


    【解决方案1】:

    您需要使用 SKPhysicsJoint。

    有多种类型,您可以在此处的 Apple Developer Library 中找到更多信息:

    https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKPhysicsJoint_Ref/Reference/Reference.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多