O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scrolling a Level Selection Scene

If your game has say 20 levels, it is okay to have one single level selection scene to display all the level buttons; but what if you have more? In this section, we will modify the previous section's code, create a node, and customize the class to create a scrollable level selection scene.

Getting ready

We will create a new class called LevelSelectionLayer, inherit from CCNode, and move all the content we added to LevelSelectionScene to it. This is done so that we can have a separate class and instantiate it as many times as we want in the game.

How to do it…

In the LevelSelectionLayer.m file, we will change the code to the following:

#import "CCNode.h" @interface LevelSelectionLayer : CCNode { NSMutableArray *buttonSpritesArray; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required