5

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

antonakos
  • 7,983
  • 2
  • 29
  • 34
Oscar Gomez
  • 18,102
  • 12
  • 80
  • 113

2 Answers2

5

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
  • 9,812
  • 18
  • 89
  • 143
  • 1
    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 Jan 08 '10 at 02:40
  • 1
    Both your links are broken now :( – mik01aj May 21 '14 at 14:27
5

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

Community
  • 1
  • 1
Adam Byram
  • 1,422
  • 10
  • 8