In the next two recipes, we will experiment with the black art of integrating UIKit elements into a Cocos2d game. In this example, we see a UIKit alert dialog with choices and associated callback methods.
Execute the following code:
@interface Ch5_UIKitAlerts : Recipe <UIAlertViewDelegate>{} -(CCLayer*) runRecipe; -(void)showPieAlert; -(void)alertView:(UIAlertView*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; @end @implementation Ch5_UIKitAlerts -(CCLayer*) runRecipe { [super runRecipe]; [self showPieAlert]; return self; } //Shows a UIAlertView -(void)showPieAlert { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Do You Like Pie?" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Yes",@"No",nil]; [alert show]; [alert release]; } //AlertView callback -(void)alertView:(UIAlertView *)actionSheet...