Game Development Reference
In-Depth Information
[self initPhysics];
[self addNewSpriteAtPosition:ccp(200,200)];
[self scheduleUpdate];
}
return self;
}
-(void) dealloc
{
for (int i = 0; i < 4; i++)
{
cpShapeFree(walls[i]);
}
cpSpaceFree(space);
}
...
You can see in the dealloc method how the four wall segments are freed using
cpShapeFree , and following that the space is freed with cpSpaceFree . So let's
see how things are created in the first place. Same as before, you do the Chipmunk ini-
tialization in the initPhysics method:
-(void) initPhysics
{
cpInitChipmunk();
space = cpSpaceNew();
space-> gravity = CGPointMake(0, -100);
...
}
The very first thing you must do before using any Chipmunk methods is call cpIn-
itChipmunk . After that, you can create the space with cpSpaceNew .
Search Nedrilad ::




Custom Search