大家好,我正在用cocos2d v1开发一款游戏,我正在使用box2d。我正在启用视网膜显示。我正在制作一个水桶。我只想在x轴上移动我的铲斗,所以我做了一个b2PrismaticJoint,但问题是铲斗不适合地面。这是我的代码:`CCSprite*tube=[CCSprite spriteWithFile:@“tube.png”];
管位置=ccp(螺纹宽度/2,螺纹高度/2);
[self-addChild:tube];
b2BodyDef bucketBodyDef;
bucketBodyDef.type = b2_dynamicBody;
bucketBodyDef.position.Set(tube.contentSize.width/PTM_RATIO, tube.contentSize.height/PTM_RATIO);
bucketBodyDef.userData = tube;
tubeBody = world->CreateBody(&bucketBodyDef);
b2PolygonShape bucketShape;
bucketShape.SetAsBox(tube.contentSize.width/2/PTM_RATIO, tube.contentSize.height/2/PTM_RATIO);
// Create shape definition and add to body
b2FixtureDef bucketShapeDef;
bucketShapeDef.shape = &bucketShape;
bucketShapeDef.density = 10.0f;
bucketShapeDef.friction = 0.4f;
tubeFixture = tubeBody->CreateFixture(&bucketShapeDef);
[self createTubeFixtures];
// Restrict bucket along the x axis
b2PrismaticJointDef jointDef;
b2Vec2 worldAxis(1.0f, 0.0f);
jointDef.collideConnected = true;
jointDef.Initialize(tubeBody, groundBody,
tubeBody->GetWorldCenter(), worldAxis);
world->CreateJoint(&jointDef);`
当我把接头拆下来时,一切都好。。请看附件中的图片。谢谢