I have a usual iOS Cocos2d game. I start with a MainMenuViewController, which then pushes my rootViewController when the "new game" button is pressed, which then sets up the cocos2d scene and the HelloWorldLayer. Im not sure if any of that relevant.
The problem is when I want to end my game. When the player has 0 lives left and a certain collison is detected, I want the scene to end, and I want to pop back to my main menu. So I call the following method from within my update: (ccTime) dt
method immediately after collision is detected:
-(void)endScene {
[[SimpleAudioEngine sharedEngine] stopBackgroundMusic];
[[CCDirector sharedDirector] end];
[_rootViewController.navigationController popViewControllerAnimated:YES];
}
The problem is that when ending the scene, I get a variety of EXC_BAD_ACCESS
errors. The one I get most often is in CCScheduler.m:
// delete all updates that are marked for deletion
// updates with priority < 0
DL_FOREACH_SAFE( updatesNeg, entry, tmp ) {
if(entry->markedForDeletion )
{
[self removeUpdateFromHash:entry]; //THIS IS WHERE IS GET EXC_BAD_ACCESS
}
}
The only thing logged by Cocos2d is
2012-03-02 13:36:20.849 Psycho Circles[25265:707] cocos2d: deallocing <CCScheduler: 0x3a3330>
Any help would be appreciated!