Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2d box2d: different mass but body fall at same time

I have created 2 box2d body with cocos2d sprite....they have different mass and they fall from same place in the world. but they fall ground at the same time. my idea is that the lighter body should fall later then the heavier one.....but they didn't.

for (int k=1;k<=2; k++) {
    int idx = (CCRANDOM_0_1() > .5 ? 0:1);
    int idy = (CCRANDOM_0_1() > .5 ? 0:1);
    CCSprite *sprite = [CCSprite spriteWithBatchNode:batch rect:CGRectMake(32 * idx,32 * idy,32,32)];
    [batch addChild:sprite];

    sprite.position = ccp( p.x+(32*k), p.y);


    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;

    bodyDef.position.Set(( p.x+(32*k))/PTM_RATIO, p.y/PTM_RATIO);
    bodyDef.userData = sprite;

    b2Body *body = world->CreateBody(&bodyDef);


    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box


    b2FixtureDef fixtureDef;
    fixtureDef.shape = &dynamicBox; 
    fixtureDef.density = 1.0f/k;
    fixtureDef.friction = 0.3f;
    body->CreateFixture(&fixtureDef);
    NSLog(@"%f",body->GetMass());
}
like image 642
Rony Avatar asked Dec 03 '22 02:12

Rony


1 Answers

Well, Galileo Galilei discovered that all objects drop with the same speed...

https://web.archive.org/web/20100728100438/http://galitzin.mines.edu/INTROGP/notes_template.jsp?url=GRAV%2FNOTES%2Ffallb.html&page=Gravity%3A%20Notes%3A%20Falling%20Bodies

like image 176
AndreasLoew Avatar answered Jan 03 '23 14:01

AndreasLoew