I try to use chipmunk collisions to tell me if a car collided with a powerup in my game.
Unfortunately I'm having problems with cpSpaceAddCollisionPairFunc right now.
My stripped down code looks like this:
Code: Select all
int Phys_CollectPowerup (cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data)
{
[...]
}
static void Phys_Init (void)
{
cpInitChipmunk();
e.physics = cpSpaceNew();
[...]
cpSpaceAddCollisionPairFunc(e.physics, COLL_CAR, COLL_POWERUP, &Phys_CollectPowerup, NULL); //&some_value);
}
COLL_CAR and COLL_POWERUP are 1 and 2 respectively.
They are set for cars and powerups like this
Code: Select all
shape->collision_type = COLL_CAR;
and
shape->collision_type = COLL_POWERUP;
My problem is that Phys_CollectPowerup is never called.
Any ideas what I could've missed?
Is the order of adding shapes/bodies and the collision pair function important?
Thanks in advance,
Martin