O'Reilly logo

Mastering Cocos2d Game Development by Alex Ogorek

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 a scene up and running

Before we even start adding anything to the screen, we need to make sure we have a game that can be viewed on our device or a simulator. Once you've created the project in SpriteBuilder (or gotten the blank project that was listed earlier) and opened the project in Xcode, go to the next step.

Creating the initial code for the scene to open

You should see a file called MainScene.h and another file called MainScene.m. Open the header file (which has the .h extension).

In the header file, add a few lines of code between the @interface line and the @end line. The header should look like this:

@interface MainScene : CCNode
{
  CGSize winSize;
}
+(CCScene*)scene;
@end

Then, in the main file (which has the .m extension), some ...

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