Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chipmunk collision detection

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

like image 745
Oscar Gomez Avatar asked Jan 08 '10 02:01

Oscar Gomez


2 Answers

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://chipmunk-physics.net/release/ChipmunkLatest-Docs/#CollisionCallbacks

like image 135
Adam Byram Avatar answered Sep 17 '22 01:09

Adam Byram


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

like image 32
Hamish Grubijan Avatar answered Sep 18 '22 01:09

Hamish Grubijan