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 Gameplay Scene

After the play button is pressed, to actually transition to another scene, we need a new scene to create a transition into. So, let's take a look at how to create one.

Getting ready

Let's us now add a gameplay scene. Creating the file is similar to how we created it in the previous chapter.

How to do it…

Here, I created a class called GameplayScene. The Gameplay.h file should be as follows:

#import "CCScene.h"

@interface GameplayScene : CCNode

+(CCScene*)scene;
-(id)initWithLevel:(NSString*)lvlNum

@end

The GameplayScene.m file should be as follows:

#import "GameplayScene.h" #import "cocos2d-ui.h" @implementation GameplayScene +(CCScene*)scene{ return[[self alloc]initWithLevel:lvlNum]; } -(id)initWithLevel:(NSString*)lvlNum{ if(self ...

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