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

Adding a Level Selection Scene

In this section, we will take a look at how to add a level selection scene in which you will have buttons for each level you want to play, and if you select it, this particular level will load up.

Getting ready

To create a level selection screen, you will need a custom sprite that will show a background image of the button and text showing the level number. We will create these buttons first.

Once the button sprites are created, we will create a new scene that we will populate with the background image, the name of the scene, the array of buttons, and a logic to change the scene to the particular level.

How to do it…

We will create a new Cocoa Touch class with CCSprite as the parent class and call it LevelSelectionBtn ...

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