0
votes

Using box2d and cocos2d, i need to create some b2body model , where the that body will be a line or a whole ( made of vectors with coding) that can be "pass-able" by a ball , when the ball is hitting him in high velocity .

So ,in other words ,like in the real world, the material should be soft, that can be broken.

A zero density does not do that . Is there another way for this ?

Thanks .

1
Most of games today with breakable things in them have fractured objects which they can get fractured, and also there are different ways for destruction. For partial walls like the one you say, you need to make it piece by piece. Just cut the sprite and make polygonal collision areas upon those parts.MahanGM

1 Answers

0
votes

why make One????? make the wall using bricks(Smaller particles) that will fall incase with collision.....

The other way to get this functionality is using presolve of the contactListener.... there check the collision between two bodies and if speed of one is grater than a certain value set contact disabled...

Take this code from one of my games.....

`enter code here`if ((userDataObjectA.userDataType == kObjectTypeMotherShip || userDataObjectB.userDataType == kObjectTypeMotherShip) && (userDataObjectA.userDataType == kObjectTypeSaucer || userDataObjectB.userDataType == kObjectTypeSaucer)) {
        b2WorldManifold worldManifold;
        contact->GetWorldManifold(&worldManifold);
        if (userDataObjectA.userDataType == kObjectTypeSaucer) {
            b2Vec2 saucerVelocity = bodyA->GetLinearVelocity();
            if (saucerVelocity.y > 2) {
                contact->SetEnabled(false);
            }
        } else if (userDataObjectB.userDataType == kObjectTypeSaucer) {
            b2Vec2 saucerVelocity = bodyB->GetLinearVelocity();
            if (saucerVelocity.y > 2) {
                contact->SetEnabled(false);
            }
        }
  }