gpt4 book ai didi

ios - 我如何将 "pin" Sprite 转换为 Sprite Kit 中的其他 Sprite ?

转载 作者:行者123 更新时间:2023-11-28 22:23:42 28 4
gpt4 key购买 nike

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

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

这是我用来将胸部连接到头部的代码,关于如何实现这一点有什么想法吗?

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;

最佳答案

您需要使用 SKPhysicsJoint。

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

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

关于ios - 我如何将 "pin" Sprite 转换为 Sprite Kit 中的其他 Sprite ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19579586/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com