box2d世界::一切都那么轻!

时间:2010-10-11 10:22:57

标签: iphone box2d-iphone

我正在使用box2d 2.1.2和cocos2d 0.99.4

在我的世界里,一切都很轻, 扔石头或盒子没有感觉! 一切都以同样的速度慢慢下降

b2Vec2 gravity; 
gravity.Set(0.0f, -10.0f);
bool doSleep = true;
world = new b2World(gravity, doSleep);

和我的对象:

b2BodyDef *TBodyDef = new b2BodyDef;
    TBodyDef->position.Set(100, 200);
    b2Body *TBody = world->CreateBody(TBodyDef);
    TBody->SetType(b2_dynamicBody);
    TBody->SetAwake(true);
    b2CircleShape TCircleShape;
    TCircleShape.m_radius = 20;
    b2FixtureDef TFixtureDef;
    TFixtureDef.shape = &TCircleShape;
    TFixtureDef.friction = 0.1;
    TFixtureDef.density = 0.1;
    TFixtureDef.restitution = 1;
    TFixtureDef.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody->CreateFixture(&TFixtureDef);

    b2BodyDef *TBodyDef1 = new b2BodyDef;
    TBodyDef1->position.Set(200, 200);
    b2Body *TBody1 = world->CreateBody(TBodyDef1);
    TBody1->SetType(b2_dynamicBody);
    TBody1->SetAwake(true);
    b2CircleShape TCircleShape1;
    TCircleShape1.m_radius = 20;
    b2FixtureDef TFixtureDef1;
    TFixtureDef1.shape = &TCircleShape;
    TFixtureDef1.friction = 0.1;
    TFixtureDef1.density = 0.5;
    TFixtureDef1.restitution = 1;
    TFixtureDef1.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef1.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody1->CreateFixture(&TFixtureDef1);

和我的步骤:

int32 velocityIterations = 8;
int32 positionIterations = 3;

world->Step(dt, velocityIterations, positionIterations);

密度不会改变坠落的速度。 是什么让它像这样流动: link text

谢谢你的帮助

1 个答案:

答案 0 :(得分:4)

物体密度不会影响它所处的速度。

否定空气阻力和其他通常可以忽略不计的效果,所有物体都会以相同的速度下降。

如何测试:拿起一些灯(例如你的朋友iPhone 4)和重物(你的旧CRT)并在同一时间将它们从窗口中取出。