views:

682

answers:

2

Hello,

I am completely new to chipmunk and I have just been using it for a few days, so I'm guessing this is something pretty obvious, however I cannot find any documentation for this. Is there any callback or method in chipmunk that tells you that 2 given shapes have collided?.

If not is the best way to simply use cgrectcontains on the sprites?.

-Oscar

+1  A: 

Does this help:

http://code.google.com/p/chipmunk-physics/wiki/CollisionDetection

// Reference line
// Does not collide with other objects, we just want to draw it.
shape = cpSegmentShapeNew(staticBody, cpv(-320,0), cpv(320,0), 0.0f);
shape->collision_type = 1;
cpSpaceAddStaticShape(space, shape);
// Add a collision pair function to filter collisions
cpSpaceAddCollisionPairFunc(space, 0, 1, NULL, NULL);

Finally, use Google Code Search:

http://www.google.com/codesearch?q=lang:c+chipmunk+collision&hl=en&btnG=Search+Code

Hamish Grubijan
I don't believe this code sample works with the latest Chipmunk library...it's the old method of doing it. Now the collision functions split the collision into several stages.
Adam Byram
+1  A: 

You can get to it from Ipthnc's link, but this is the documentation you're probably looking for - it details the collision callback system:

http://code.google.com/p/chipmunk-physics/wiki/CallbackSystem

Adam Byram
I did all the leg work and got a -1 ... so sad :(
Hamish Grubijan
I just leveled you to 0 for your help :). But I will choose this answer as it is more updated.
OscarMk
Jawohl! Vielen Dank!
Hamish Grubijan