Hello. My app keeps crashing when i try to destroy a distance joint when two bodies collide.
heres the code for my joint:
//distance joint #1
myjoint.Initialize(ballBody, ball10Body, ballBody->GetPosition(), ball10Body->GetPosition());
myjoint.collideConnected = true;
JointA = (b2DistanceJoint*) _world->CreateJoint(&myjoint);
and heres the code in my tick method to destroy the joint:
std::vector<b2DistanceJoint *>toDestroy;
std::vector<MyContact>::iterator pos;
for(pos = _contactListener->_contacts.begin();
pos != _contactListener->_contacts.end(); ++pos) {
MyContact contact = *pos;
if ((contact.fixtureA == _paddleFixture && contact.fixtureB == _ballFixture) ||
(contact.fixtureA == _ballFixture && contact.fixtureB == _paddleFixture)) {
NSLog(@"Paddle Hit Box #1");
_world->DestroyJoint(JointA);
I'm not sure if i did this right but if someone would help me it would be appreciated.
-Nick Homme