Wednesday, November 7, 2012

Remove all objects in cocos2d game world with box2d


You can remove all objects in cocos2d game world with box2d


for(b2Body *b = _world->GetBodyList(); b; b=b->GetNext()) {
        if (b->GetUserData() != NULL) {
            CCSprite *sprite = (CCSprite *)b->GetUserData();
            [self removeChild:sprite cleanup:YES];
            _world->DestroyBody(b);
           
        }
    }