Using CCParallaxNode
Parallaxing is a staple of 2D side-scrolling video games. A competent developer would be remiss if he didn't include a nice parallaxed background in a 2D side-scroller. Cocos2d makes parallaxing easy with CCParallaxNode.
Getting ready
Please refer to the project RecipeCollection01
for full working code of this recipe.
How to do it...
Execute the following code:
@implementation Ch1_UsingCCParallaxNode -(CCLayer*) runRecipe { //Create four parallax sprites, one for each layer CCSprite* parallaxLayer01 = [CCSprite spriteWithFile:@"parallax_layer_01.png"]; CCSprite* parallaxLayer02 = [CCSprite spriteWithFile:@"parallax_layer_02.png"]; ...
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.