So in my game I have Cocos2D + Box2D integrated. I know it is not recommended but I have my b2Bodys follow my CCSprites because I only need the collision part of Box2D. Anyway, using PhysicsEditor, I have created the most efficient body shapes I can and my game normally runs fine at 60FPS. My only issue is that, I want to prepare for the worst here. Lets say just under a really rare occurrence (like 1 in 10,000) the game lags for 5 seconds so that the FPS is around 10FPS. This would cause my main character to not collide with the platform under it. And in turn, it would make the character fall through the platform and the game would end unintentionally. So overall I just want to have a fallback plan when this happens.
So this is how I call the Box2D step:
world->Step(1/60.0f ,8, 8);
Then in my update method I do this to detect the collisions:
std::vector<b2Body *>toDestroy;
std::vector<MyContact>::iterator pos;
for(pos = _contactListener->_contacts.begin();
pos != _contactListener->_contacts.end(); ++pos) {
MyContact contact = *pos;
b2Body *bodyA = contact.fixtureA->GetBody();
b2Body *bodyB = contact.fixtureB->GetBody();
if (bodyA->GetUserData() != NULL && bodyB->GetUserData() != NULL) {
CCSprite *spriteA = (CCSprite *) bodyA->GetUserData();
CCSprite *spriteB = (CCSprite *) bodyB->GetUserData();
if (spriteA.tag == 1 && spriteB.tag == 2) {
toDestroy.push_back(bodyA);
} else if (spriteA.tag == 2 && spriteB.tag == 1) {
toDestroy.push_back(bodyB);
}
}
}
So how would I adjust what I am doing now to deal with the possible scenario I explained above? Thanks!