Creating a horizontal scrollable menu

Cocos2d provides the rather mundane CCMenuItemToggle class to iterate through multiple CCMenuItem choices. In this example, we'll spice this up with the LoopingMenu class that mimics the iPod Touch album art shuffling visual technique.

Creating a horizontal scrollable menu

Getting ready

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

How to do it...

Execute the following code:

#import "LoopingMenu.h" @implementation Ch5_HorizScrollMenu -(CCLayer*) runRecipe { [super runRecipe]; message.position = ccp(70,270); /* Create 5 default sprites and 'selected' sprites */ CCSprite *book1 = [CCSprite spriteWithFile:@"book1.jpg"]; ...

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.