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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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