Using CCMenu

Cocos2d provides menu tools that make the process of creating a simple menu very easy. In this example, we will see how to create a simple menu, adjust menu alignment, enable/disable menu items, and more.

Using CCMenu

Getting ready

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

How to do it...

Execute the following code:

@implementation OptionsMenu +(id) scene { //Create a scene CCScene *s = [CCScene node]; OptionsMenu *node = [OptionsMenu node]; [s addChild:node z:0 tag:0]; return s; } -(id) init { if( (self=[super init] )) { /* CODE OMITTED */ //Disabled title label for Sound option CCMenuItemFont *title1 = [CCMenuItemFont ...

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.