Wrapping UIKit

Other UIKit classes offer a wide range of time-tested UI functionality. Cocos2d requires the use of a UIKit wrapper to transform UIKit objects into CCNode objects, so that they may be manipulated properly. In this example, we will wrap two different classes and manipulate them onscreen.

Wrapping UIKit

Getting ready

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

How to do it...

Execute the following code:

#import "CCUIViewWrapper.h" @implementation Ch5_WrappingUIKit -(CCLayer*) runRecipe { [super runRecipe]; [self addSpinningButton]; [self addScrollView]; return self; } -(void) addSpinningButton { //Label CCLabelBMFont ...

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.