I need to destroy one of the body's after collision in JBox2D android game. I found that JBox2D world become locked when body's become in contact. I wanted to destroy one of the body after collision. Can i get any call back after world released lock ?. I found an option that adding the body's into an array for destroying it. But when to destroy the body ?. I am not using andengine/libgdx in this game. Find my collision listener class below,
private class CollisionListener implements ContactListener {
@Override
public void beginContact(Contact contact) {
Object fixtureA = contact.getFixtureA().getUserData();
Object fixtureB = contact.getFixtureB().getUserData();
Body mBodyA = contact.getFixtureA().getBody();
Body mBodyB = contact.getFixtureB().getBody();
if (fixtureA instanceof Bullet) {
destroyBalloonBody(mBodyB);
}
if (fixtureB instanceof Bullet) {
destroyBalloonBody(mBodyA);
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void postSolve(Contact contact, ContactImpulse contactImpulse) {
}
@Override
public void preSolve(Contact contact, Manifold manifold) {
}
}
public void destroyBalloonBody(Body balloon){
//Can i start a new thread which is having a loop until the world become release for destroying the body
//Or
//Do i need to add the body to a deletionArrayList to destroy it.
}