Working on my iPhone Game (Getting pretty close, too! ) and I have some collisions working beautifully but for some reason this one is leading to crashes.
Basically, it's a cpCircle colliding with a cpPolyShape and when they collide I'm just removing the cpPolyShape.
Here's the code for creating the poly shape and setting the collision up:
Code: Select all
stopwatchToken = cpPolyShapeNew(shelvesBody, 4, stopwatchVects, cpvzero);
stopwatchToken->collision_type = 3;
cpSpaceAddCollisionPairFunc(space, 1, 3, &hitStopwatch, space);
Code: Select all
static int hitStopwatch(cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data)
{
cpShapeFree(stopwatchToken);
cpSpaceRemoveShape(space, stopwatchToken);
cpSpaceRemoveCollisionPairFunc(space, 1, 3);
return 1;
}
Code: Select all
static int hitStopwatch(cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data)
{
//cpShapeFree(stopwatchToken);
//cpSpaceRemoveShape(space, stopwatchToken);
cpSpaceRemoveCollisionPairFunc(space, 1, 3);
return 1;
}