Im trying to make a hero class for chipmunk. So far I have this in my header:
@interface Hero: cpCCSprite {
cpShape *shape;
cpSpace *space;
}
+(id)hero;
-(id)initHero;
and this in my m file:
@implementation Hero
+ (id)hero {
NSLog(@"inside hero class method");
return [[self alloc] initHero];
}
- (id) initHero {
self = [super initWithFile:@"ball.png"];
if(self != nil) {
cpBody *body = cpBodyNew(250.0f, INFINITY);
body->p = self.position;
shape = cpCircleShapeNew(body, 29.0f, cpvzero);
shape->data = self;
shape->e = 0.8;
shape->u = 0.7;
shape->collision_type = 2;
}
return self;
}
then i init it in my gamescreen with:
ball = [Hero hero];
[self addChild:ball];
However, it does not react in the gamescreen...it should fall to the bottom. How do I get my hero class to react to the spacemanager?