O'Reilly logo

Cocos2d for iPhone 0.99 Beginner's Guide by Pablo Ruiz

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

Time for action - peeking at the HelloWorldScene class

  1. Start by opening the HelloWorldScene.h file. Let's analyze it line by line:
    #import "cocos2d.h"
    

    Each class you create that makes use of Cocos2d should import its libraries. You do so by writing the preceding line.

    // HelloWorld Layer
    @interface HelloWorld : CCLayer
    {
    }
    // returns a Scene that contains the HelloWorld as the only child
    +(id) scene;
    @end
    

    These lines define the Interface of the HelloWorld CCLayer.

    A CCLayer is where all the content of your game goes. We'll explain it better soon, but for now, think of them as in any graphic design software, where you can have as many layers as you want and each of them contains different elements. Layers are also responsible for handling touches ...

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