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

发布于 2024-09-27 09:51:12 字数 1823 浏览 0 评论 0原文

在我的世界中使用 box2d 2.1.2 和 cocos2d 0.99.4,一切都很轻, 没有掉落石头或盒子的感觉! 一切都以相同的速度缓慢下落

b2Vec2 重力; 
重力.Set(0.0f,-10.0f);
布尔 doSleep = true;
world = new b2World(重力, 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);

密度对下落的速度没有任何改变。 要使它像这样流畅,还缺少什么: 链接文本

谢谢你的帮助

i'm using box2d 2.1.2 with cocos2d 0.99.4

in my world, everything is light,
there is no sensation about dropping a stone or a box !!
everything falling slowly at the same speed

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

and my objects :

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);

and my step :

int32 velocityIterations = 8;
int32 positionIterations = 3;

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

density changes nothing about the speed of falling.
what is missing to make it as fluid as this :
link text

thank you for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫雨熙 2024-10-04 09:51:12

物体的密度不会影响它下落的速度。

消除空气阻力和其他通常可以忽略不计的影响,所有物体都会以相同的速度下落。

如何测试:拿起一些轻的东西(例如你朋友的 iPhone 4)和一些重的东西(你的旧 CRT),然后将它们同时扔出窗外。

An objects density does not affect the speed it falls at.

Negating air-resistance and other generally negligible effects all objects DO fall at the same speed.

How to test this: Pick up something light (e.g. your friends iPhone 4) and something heavy (your old CRT) and drop them out of a window at exactly the same time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文