UIKit alert dialogs

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.

UIKit alert dialogs

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

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]; ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.