i am using cocos2d and box2d, with contact listener, and lets say i have a body that can hit a number of other bodies, BUT each one of them is turn on the contact listener. so how can i know who hit who ?
i have this in my tick :
for(pos = _contactListener->_contacts.begin(); pos != _contactListener->_contacts.end(); ++pos)
{
MyContact contact = *pos;
b2Body *bodyA=contact.fixtureA->GetBody();
b2Body *bodyB=contact.fixtureB->GetBody();
//check if collision between to bodies
if( bodyA->GetUserData() !=NULL && bodyB->GetUserData() !=NULL) //if ((contact.fixtureA == _bottomFixture && contact.fixtureB == _ballFixture) ||(contact.fixtureA == _ballFixture && contact.fixtureB == _bottomFixture))
{
NSLog(@"Ball hit bottom!");
}
thanks a lot .