I think there's probably a very simple answer to this but I can't figure it out and I've been looking at it for so long it's driving me crazy. I'm just trying to read some NSUserDefaults to see if it's the first time a user is using my app. If it is, I want to pause the director and display a UIAlert. Here's my code:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL hasBlownNose = [userDefaults boolForKey:@"hasBlownNose"];
if (hasBlownNose != YES) {
[[CCDirector sharedDirector] pause];
[userDefaults setBool:YES forKey:@"hasBlownNose"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"How to use a tissue..." message:@"Use one or two fingers to pull a tissue out of the box. \"Blow\" your nose into it. Fold it up and throw it in the trash can... or not!" delegate:self cancelButtonTitle:@"Got it!" otherButtonTitles:nil];
[alert show];
[alert release];
}
And later on:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[[CCDirector sharedDirector] pause];
}
So right now I have a pause call in both the UIAlert code and in the alertView method. The only reason I was doing this is because my game wouldn't pause when the alert pops up (at the time of the first director pause call). So I decided to see if it would pause later on so I put a director pause call in the alertView method and that one works...
I have no Idea what's wrong with this. I've compared it to other things that I've done like this and it all lines up.
Any ideas are welcomed.
I'm also wondering if it's bad practice to put my [alert release] call where I have it there, right after I call [alert show].. ?
Thanks!
- Joe