Hi,
I'm trying to destroy bodies, but keep getting
Program received signal: “EXC_BAD_ACCESS”.
And the code jumps to b2World.cpp void - b2World::DestroyBody(b2Body* b) with a red arrow at:
b2JointEdge* je = b->m_jointList;
The only thing I have done with this sprite/body before destroying it is create it/display it and then in the ccTouchesBegan:
[self mySpriteTouched]; is a method where the sprite/body is destroyed:
So I create the sprite and its body and then if it gets touched (attempt to) destroy it.
I know my sprite/body creation is working because I have another sprite and body which I create that gets destroyed if the user touches a certain other sprite on the screen. This works fine and the sprite and body both disappear. So the only difference as far as I can see is the bit in the touchesBegan.
Any ideas what's wrong?
Thanks for any help...
I'm trying to destroy bodies, but keep getting
Program received signal: “EXC_BAD_ACCESS”.
And the code jumps to b2World.cpp void - b2World::DestroyBody(b2Body* b) with a red arrow at:
b2JointEdge* je = b->m_jointList;
The only thing I have done with this sprite/body before destroying it is create it/display it and then in the ccTouchesBegan:
Code:
for (b2Fixture* f = mySpritesBody->GetFixtureList(); f; f = f->GetNext()) {
if (f->TestPoint(touchCoords)) {
[self mySpriteTouched];
}
}
if (f->TestPoint(touchCoords)) {
[self mySpriteTouched];
}
}
[self mySpriteTouched]; is a method where the sprite/body is destroyed:
Code:
[gameLayer removeChild:mySprite cleanup:YES];
_world->DestroyBody(mySpritesBody);
_world->DestroyBody(mySpritesBody);
So I create the sprite and its body and then if it gets touched (attempt to) destroy it.
I know my sprite/body creation is working because I have another sprite and body which I create that gets destroyed if the user touches a certain other sprite on the screen. This works fine and the sprite and body both disappear. So the only difference as far as I can see is the bit in the touchesBegan.
Any ideas what's wrong?
Thanks for any help...