Reputation: 2576
I'm very experienced with Cocos2d and Box2d, and wanted to try Chipmunk instead. Everything works fine as long as I add sprites to the helloworldlayer, but if I add another layer and attempt to add a sprite to that new layer it crashes.
It fails with an EXC_BAD_ACCESS in the cpSpaceStep function call in the update on the main layer.
-(void) update:(ccTime) delta
{
// Should use a fixed size step based on the animation interval.
int steps = 2;
CGFloat dt = [[CCDirector sharedDirector] animationInterval]/(CGFloat)steps;
for(int i=0; i<steps; i++){
HERE -> cpSpaceStep(space_, dt);
}
}
EDIT: The problem seems to be regarding sprite batch nodes and not CCLayers.
Upvotes: 0
Views: 143
Reputation: 1409
Chipmunk doesn't actually interact directly with Cocos2D, it's just a physics engine. So if it's crashing in cpSpaceStep() with an EXC_BAD_ACCESS it's almost certainly because you gave Chipmunk a dangling pointer somewhere or have another memory bug that's corrupting data that Chipmunk is using.
If you compile it as debug, where does it crash exactly? Are you using any callbacks at all and are sure it's not happening in one of those?
Upvotes: 1