If you upgraded to Chipmunk 5, the collision system was vastly improved to provide more callbacks.
Basically there's 4 callbacks at various stages of a collision: Begin, Presolve, Postsolve, and Separate. You are not required to implement all these, only what you need, but it gives you much more flexibility in your app.
The new function to add a collision handler is:
void cpSpaceAddCollisionHandler(
cpSpace *space,
cpCollisionType a, cpCollisionType b,
cpCollisionBeginFunc begin,
cpCollisionPreSolveFunc preSolve,
cpCollisionPostSolveFunc postSolve,
cpCollisionSeparateFunc separate,
void *data
)
so if you want to continue using your old code, just use your current callback function as the Begin callback, and put NULL for the rest.
eg. cpSpaceAddCollisionPairFunc(_gameSpace, 0, 1, &spriteCollision, NULL, NULL, NULL, self);
The callback function itself has also changed slightly to:
typedef int (*cpCollisionBeginFunc)(cpArbiter *arb, struct cpSpace *space, void *data)
typedef int (*cpCollisionPreSolveFunc)(cpArbiter *arb, struct cpSpace *space, void *data)
typedef void (*cpCollisionPostSolveFunc)(cpArbiter *arb, struct cpSpace *space, void *data)
typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, struct cpSpace *space, void *data)
The callback setup was the only change I had to make when upgrading Chipmunk in my current Cocos 2d v0.8.2 project.
Make sure you have the latest Chipmunk (v5.1) which is available in the latest Cocos2d revision on SVN. In Chipmunk v5.0 a return 0 (ignore collision) in the BEGIN stage of the collision did not translate over to the rest of the stages.
In addition, Chipmunk 5+ also added a nice feature that basically allows you mark a shape for deletion in a collision callback. It's called a Post Step callback. As you may or may not now, you cannot delete a shape involved in a collision within a collision callback (or the app will crash), so I thought this was really nice new feature :)
More info on all of this can be found here: http://code.google.com/p/chipmunk-physics/wiki/CallbackSystem
- kalx