My cocos2d+box2d application freeze/stop sometimes. Pause from debugger get this line from b2World.cpp. What does it mean? Maybe problem with my contactlistener, without it app work at normal mode.
**// Clear all the island flags.
for (b2Body* b = m_bodyList; b; b = b->m_next)
{
b->m_flags &= ~b2Body::e_islandFlag;**
My contactlistener. Detect collision -> check Filters -> push_back(body) -> add body into destroyArray -> destroy body after timestep in update method.
std::vector<b2Body *>toEat;
std::vector<MyContact>::iterator pos3;
for (pos3 = _contactListener->_contacts.begin(); pos3 != _contactListener->_contacts.end(); ++pos3) {
MyContact contact = *pos3;
b2Body *bodyA = contact.fixtureA->GetBody();
b2Body *bodyB = contact.fixtureB->GetBody();
if (bodyA->GetUserData() != NULL & bodyB->GetUserData() != NULL) {
b2Fixture *fixtureA = bodyA->GetFixtureList();
b2Filter filterA = bodyA->GetFixtureList()[0].GetFilterData();
b2Filter filterB = bodyB->GetFixtureList()[0].GetFilterData();
//some filter stuff
if (filter == my filter) {
toEat.push_back(bodyB);
}
}
}
std::vector<b2Body *>::iterator pos4;
for(pos4 = toEat.begin(); pos4 != toEat.end(); ++pos4) {
b2Body *body = *pos4;
if (body->GetUserData() != NULL) {
CCPhysicsSprite *sprite = (CCPhysicsSprite*)body->GetUserData();
[self removeChild:sprite cleanup:YES];
body->SetActive(false);
[bodiesForDestroy addObject:[NSValue valueWithPointer:body]];
}
}