so I am having some problems with chipmunk, please realize that I am new and am just learning many of the ideas around chipmunk and if you have any good books, sources, or websites that I could use to learn chipmunk that would be great (please only current guides, I have walked through many old guides with outdated commands and have been quite frusterated).
but on to my main question, I am using Chipmunk and have used the "chipmunk tutorial" code that I found on an online web source. I am trying to attach an image (UIImageView *ball;) to the ballBody->data
section, and trying to update the image but can not seem to figure it out, the code works but the image only moves to the ballBodys initial position.
Here is a sample of the code I'm using, let me know if I should supply any more information!
This is a timer that I call to update the chipmunk frames, When I call the "cpSpaceHashEach(space->activeShapes, &updateShape, nil);" section of the code I get the error that there is no object in called "active shapes in the struct cpspace, and thecpSpaceHash has an implicit declaration
// Called at each "frame" of the simulation
- (void)tick:(NSTimer *)timer {
// Tell Chipmuck to take another "step" in the simulation
cpSpaceStep(space, 1.0f/60.0f);
// Call our function for each shape
cpSpaceHashEach(space->activeShapes, &updateShape, nil);
}
I think you are looking at a tutorial for 5.x and using Chipmunk 6.x.
"cpSpace.activeShapes" was documented as a private member in 5.x and is now gone. cpSpaceHashEach() was undocumented. It wasn't recommended to iterate the shapes using the snippet you gave because it caused a lot of undefined behavior, but everybody did it anyway.
In 6.x you should do this as it doesn't use any private, undocumented or undefined functionality:
cpSpaceEachShape(space, updateShape, NULL);
That said, I still wouldn't recommend iterating the shapes that way. You should keep a list of them yourself so you don't end up needing to skip static shapes and such.
You should take a look at the Simple Objective-Chipmunk Tutorial or the Snap example project on the Chipmunk downloads page: http://chipmunk-physics.net/downloads.php