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 - building blocks

We'll create a new class named TouchableBlock, which will hold the logic for making the blocks disappear. Then we will create three classes that will be subclasses of this TouchableBlock class. Each of these will represent the geometric figures that I just mentioned.

  1. Create a new class named TouchableBlock.
  2. Replace the TouchableBlock.h contents with the following lines:
    #import <Foundation/Foundation.h> #import "cocos2d.h" #import "chipmunk.h" typedef enum tagState { kStateGrabbed, kStateUngrabbed } touchState; @class GameLayer; @interface TouchableBlock : CCNode <CCTargetedTouchDelegate> { CCSprite * mySprite; cpBody * myBody; cpShape * myShape; GameLayer * theGame; touchState state; } @property (nonatomic,retain) ...

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