Search code examples
ioscocos2d-iphonechipmunk

cpSpaceHashEach - 2 problems at the same line


I'm trying to grasp basics of Chipmunk. In some tutorial I found a line:

cpSpaceHashEach(space->activeShapes, &updateShape, nil);

But I get 2 mistakes here:

1) Implicit declaration of function is invalid in C99

2) No member named 'activeShapes' in 'struct cpSpace'

What is wrong? Why doesn't it work? Do I need to include something else?


Solution

  • Digging into the changelog: (https://github.com/slembcke/Chipmunk-Physics/blob/master/VERSION.txt)

    If you look, you'll find that in Chipmunk 5.x cpSpace.*Shapes were marked as private members of the cpSpace struct in the header. Then, in Chipmunk 6.x, private access was disabled by default and a cpSpaceEachShape() function appeared that almost exactly replaced cpSpaceHashEach() + cpSpace.activeShapes that you are trying to do.