iphonecocos2d-iphonebox2dbox2d-iphone

Want label to display on ball collision in cocos2d and box2d application


I'm using _world->step(dt,5,5) to detect the collision system. So collision is actually getting handled by box2d classes. Now I want to show score on balls collision depending on to which ball it has collide?

Can any one please help me out with this? If you guys want I can provide source code of tick function if required.

Your help is appreciated.

Thank you,

Ankita


Solution

  • create a fixture for each body and in tick function check for collision...

    if((contact.fixtureA == fixture1 && contact.fixtureB == fixture2) ||
    (contact.fixtureA == fixture2 && contact.fixtureB == fixture1))
    {
    //do something
    }
    

    Hope this helps!!!!