Okay... Very basic question. New here. I come from a Chipmunk background.
Now, I have created a filter maskbit and category for may main character. I am also creating a body dynamically (on touch end) with maskbit and category filtering properties. I have set up my contact listener class and have instantiated that, and set the world to listen for it.
My issue is that the dynamically created body's filerting methods are not being captured by the world. A Google Search revealed to me that in the Flash version of Box2D, you have to perform the m_world->Refilter() method. There is no such method in the iPhone version, however.
Can someone help me out with this issue?
Thanks,
Code for my contact listener class is below:
Now, I have created a filter maskbit and category for may main character. I am also creating a body dynamically (on touch end) with maskbit and category filtering properties. I have set up my contact listener class and have instantiated that, and set the world to listen for it.
My issue is that the dynamically created body's filerting methods are not being captured by the world. A Google Search revealed to me that in the Flash version of Box2D, you have to perform the m_world->Refilter() method. There is no such method in the iPhone version, however.
Can someone help me out with this issue?
Thanks,
Code for my contact listener class is below:
Code: Select all
const uint16 ENEMY_BIT = 0x0003;
const uint16 CHARACTER_BIT = 0x0004;
class MyContactListener : public b2ContactListener {
public:
void BeginContact(b2Contact* contact)
{
//check if fixture A was a ball
b2Filter filterA = contact->GetFixtureA()->GetFilterData();
b2Filter filterB = contact->GetFixtureB()->GetFilterData();
bool collide = (filterA.maskBits & filterB.categoryBits) != 0 &&
(filterA.categoryBits & filterB.maskBits) != 0;
if (filterA.categoryBits == ENEMY_BIT)
NSLog(@"This is a test");
}
// ...
}
};