BOX2D статическое трение тела - PullRequest
0 голосов
/ 14 июля 2011

Я создаю заземление следующим образом:

    // Define the ground body.
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0, 0); // bottom-left corner

    // Call the body factory which allocates memory for the ground body
    // from a pool and creates the ground box shape (also from a pool).
    // The body is also added to the world.
    b2Body* groundBody = world->CreateBody(&groundBodyDef);

    // Define the ground box shape.
    b2PolygonShape groundBox;   

    // bottom
    groundBox.SetAsEdge(b2Vec2(0,0), b2Vec2(screenSize.width/PTM_RATIO,0));
    groundBody->CreateFixture(&groundBox,0);

    // top
    groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO));
    groundBody->CreateFixture(&groundBox,0);

    // left
    groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
    groundBody->CreateFixture(&groundBox,0);

    // right
    groundBox.SetAsEdge(b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,0));
    groundBody->CreateFixture(&groundBox,0);

Как мне установить его трение?Спасибо.

1 Ответ

1 голос
/ 14 июля 2011

Вам необходимо создать осветитель из определения осветителя (b2FixtureDef), где вы можете установить конкретное трение. Примерно так:

b2FixtureDef fixtureDef;

fixtureDef.shape = &groundBox;
fixtureDef.density = 0.0f;
fixtureDef.friction = YOUR_FRICTION_VALUE;

groundBody->CreateFixture(&fixtureDef);
...