box2d:Disable bounce on collision

I have some box,creating using box2d,which restitution's are set to zero.but when they fall over one another there appear bounce event.but i don't want that...i want them not move when fall over can be done if i switch off gravity.but i also want is my code

UIImage *imageOfSnowV1 = [ UIImage imageNamed:[NSString stringWithFormat:@"Object%d.png",currentlySelected]];
    CCTexture2D  *texOfSnowV1 = [[ [CCTexture2D alloc] initWithImage:imageOfSnowV1 ] autorelease];
    CCSprite *sprite = [CCSprite spriteWithTexture:texOfSnowV1  rect:CGRectMake(0, 0, 32, 32)];
    [self addChild:sprite];
    sprite.position = ccp(p.x, p.y);
    sprite.tag=[temp intValue];

    // Define the dynamic body.
    //Set up a 1m squared box in the physics world

    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;

    bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
    bodyDef.userData = sprite;
    b2Body *bodyS = world->CreateBody(&bodyDef);

    // Define another box shape for our dynamic body.

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

    b2MassData massData;
    massData.mass = 0.1f;

    // Define the dynamic body fixture.
    b2FixtureDef fixtureDef;
    fixtureDef.shape = &dynamicBox; 
    fixtureDef.density = 50.0f;
    fixtureDef.friction = 0.01f;


can anyone help me?


As I remember box2d by default uses maximal restitution of colliding objects so even if you have dynamic body restitution set to 0 if the static body have any larger than 0 then that restitution will be used for collision, you could modify b2MixRestitution function to meet your needs.

Cheers, Krzysztof Zabłocki

I've been having the same problem lately. My solution, just zero-out the Y coordinate when you detect a new collision in your contact listener. It does the trick perfectly here.

you have to increase velocityIterations and positionIterations. If the bodies are fast they will overlap. so you need better calculation. depends on bodies count you might get perfomance issues, just play with this values.

int32 velocityIterations = 10;
int32 positionIterations = 8;
world->Step( timeStep, velocityIterations, positionIterations ); 

Need Your Help

cocoa nstableview dynamic binding - without IB

objective-c cocoa cocoa-bindings

I have an app that needs to present a lot of data by group. I had put a group selection menu in the table's corner view to allow the user to choose the group to view.

Smarty Master Pages

php smarty

How can I create Master Pages like in ASP.NET using PHP and Smarty?