im using box2d 2.3.1physics engine in my cocos2dx v4 project. My polygon shapes are created using physics editor. all colliding itself properly but contact listener doesnt log contacts.
this is my contactlistener header defined in helloworld.h
class MyContactListener : public b2ContactListener
{
private : void BeginContact(b2Contact* contact); void EndContact(b2Contact* contact); void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);};
this is my contactlistener implementation in helloworld.cpp
void MyContactListener::BeginContact(b2Contact* contact) { std::cout << "BeginContactn\n";
}
void MyContactListener::EndContact(b2Contact* contact) {
std::cout << "EndContact\n";
}
void MyContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) {
std::cout << "PreSolve\n";
}
void MyContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) {
std::cout << "PostSolve\n";
}
MyContactListener myContactListenerInstance;
and my contactlistener assignment to world (in helloworld.cpp init )
_rootWorld->getb2World()->SetContactListener(&myContactListenerInstance);
all works but it doesnt log collion contacts
my bodies category and bitmask values are
body A : bitmask : 63, category: 1
body B : bitmask : 63, category: 2
body C : bitmask : 63, category: 4
body D : bitmask : 63, category: 8
body E : bitmask : 63, category: 16
body F : bitmask : 63, category: 32
can anyone help?