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

Getting access to MainScene

When you launch the application, the scene created in SpriteBuilder will load up by default. We will have to make some minor changes to get access to the MainScene file and load this as default instead.

Getting ready

As of now, both the MainScene.h and MainScene.m files have nothing in them. So, open them up and add the following code in them.

How to do it…

First, open up MainScene.h and add the following highlighted code:

@interface MainScene :CCNode{

CGSizewinSize;    
}

+(CCScene*)scene;

@end

Next, in the MainScene.m file, add the following:

#import "MainScene.h @implementation MainScene +(CCScene*)scene{ return[[self alloc]init]; } -(id)init{ if(self = [super init]){ winSize = [[CCDirectorsharedDirector]viewSize]; } return ...

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