Skip to content

Instantly share code, notes, and snippets.

@szepi1991
Created January 3, 2013 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szepi1991/4446753 to your computer and use it in GitHub Desktop.
Save szepi1991/4446753 to your computer and use it in GitHub Desktop.
Remove a body from the game in AndEngine. This needs to be done on the updateThread. Code from: http://www.matim-dev.com/remove-body-completely.html
final PhysicsConnector physicsConnector =
physicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(shape);
mEngine.runOnUpdateThread(new Runnable()
{
@Override
public void run()
{
if (physicsConnector != null)
{
physicsWorld.unregisterPhysicsConnector(physicsConnector);
body.setActive(false);
physicsWorld.destroyBody(bbody);
scene.detachChild(shape);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment