I have a problem with CCDirector and UIViews
The navigation of my game basically looks like this:
MainScene -> GameOverScene -> HighScoreView(:UIView) --> and back to the MainScene...
HighScoreView opens and closes normally ONCE, but during the second round of the game, the program quits when it should load HighScoreView again. No error messages, nothing.
HighScoreView is at the moment simple UIView with one button that calls closeHighScoreViewAndStartNewGame method to hide the view and move to the next scene.
Methods in my AppDelegate:
// there's global variable HighScoreView * hs
-(void)openHighScoreView {
GameOverView *tempView = [[HighScoreView alloc] init];
selfish = tempView;
[tempView release];
[[CCDirector sharedDirector]replaceScene:[MainScene node]];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[[CCDirector sharedDirector] openGLView] cache:YES];
[[[CCDirector sharedDirector] openGLView] addSubview:go.view];
[UIView commitAnimations];
}
-(void)closeHighScoreViewAndStartNewGame {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animDone:finished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:[[CCDirector sharedDirector] openGLView] cache:YES];
[hs.view removeFromSuperview];
[UIView commitAnimations];
[hs release];
hs = nil;
}
I let MainScene run in the background because [[CCDirector sharedDirector] resume] somehow crashes the program.
Does anyone know what's wrong in my code and how to fix it? Debugger console shows no error, and neither does try-catch blocks give me any explanation.