title: How to remove colliding box2d bodies in AndEngine?
body: <p>I'm using AndEngine to create a game with box2d extension. I want to implement a condition that when two bodies collide, they should be removed or respawned. Initially I tried using</p>
  
  <pre><code>if(sprite1.collidesWith(sprite2))
  // remove the sprites
  </code></pre>
  
  <p>but this doesnt seem to help because the sprites are attached to their respective bodies. I also tried using contactListener as follows:</p>
  
  <pre><code>bodyA=getFixtureA().getBody();
  bodyB=getFixtureB().getBody();
  </code></pre>
  
  <p>and then later</p>
  
  <pre><code>if(bodyA!=null &amp;&amp; bodyB!=null)
  // remove the bodies
  </code></pre>
  
  <p>but that crashed the game. Does anybody know a better way of doing it?</p>