Box2d如何创建滑块平台

时间:2013-03-14 20:10:57

标签: cocos2d-iphone box2d

如何在Box2d中创建Slider平台?我可以像音量控制器一样从一侧移动到另一侧的平台。

1 个答案:

答案 0 :(得分:0)

    b2PrismaticJointDef jointDef;
    jointDef.Initialize(fixture->GetBody(), groundBody, fixture->GetBody()->GetWorldCenter(), b2Vec2(0.5f,0.0f));
    jointDef.maxMotorForce = 500.0;
    jointDef.enableMotor = true;
    jointDef.lowerTranslation = -2.5f;
    jointDef.upperTranslation =  2.5f;
    jointDef.enableLimit = true;