我使用for循环制作7个绳索链接精灵,无法弄清楚如何用SKPhysicsJointLimit制作绳索。 :'(
-(void)ropeStuff {
int i ;
int y;
SKSpriteNode *ropes;
SKPhysicsJointLimit * ropeLink;
NSMutableArray *ropeArray;
for (i = 0 ; i < 7; ++i) {
if (i) {
int x = 16;
y = (x * i);
ropes.position = CGPointMake(_cat.position.x, _cat.position.y + (x * i) );
}
ropes = [SKSpriteNode node];
ropes = [SKSpriteNode spriteNodeWithImageNamed:@"rope link.png"];
ropes.position = CGPointMake(_cat.position.x, _cat.position.y +5);
ropes.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:1];
ropes.physicsBody.affectedByGravity = YES;
ropes.physicsBody.dynamic = YES;
ropes.name = @"rope";
[_worldNode addChild:ropes];
if (i) {
ropeLink = [SKPhysicsJointLimit jointWithBodyA:ropes.physicsBody
bodyB:ropes.physicsBody anchorA:ropes.position anchorB:ropes.position];
[_worldNode.scene.physicsWorld addJoint:ropeLink];
}
}
}
谢谢大家的帮助! :d
答案 0 :(得分:4)
您为什么使用SKPhysicsJointLimit?绳索是一组彼此相对旋转的段。你应该使用SKPhysicsJointPin,有或没有轮换限制。