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.
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.
We will create a new Cocoa Touch class with CCSprite
as the parent class and call it LevelSelectionBtn
.
Then, we will open up the LevelSelectionBtn.h
file and add the following lines of code to it:
#import "CCSprite.h" @interface LevelSelectionBtn : CCSprite -(id)initWithFilename:(NSString *) filename StartlevelNumber:(int)lvlNum; @end
We will create...