Andengine.
Удаление объектов world-box2d должно производиться в такте andengine.
Вот код.
сначала удаляются все тела, потом соединения
public class MyPhysicsWorld extends FixedStepPhysicsWorld {
...
public void clean() {
boolean bFlagDestroy=true;
clearForces();
clearPhysicsConnectors();
Iterator<Body> allMyBodies = getBodies();
while (allMyBodies.hasNext()) {
bFlagDestroy=true;
final Body currentBody = allMyBodies.next();
destroyBody(currentBody);
}
Iterator<Joint> allMyJoints = getJoints();
while (allMyJoints.hasNext()) {
final Joint currentJoint = allMyJoints.next();
destroyJoint(currentJoint);
}
reset();
}
...
@Override
public void onUpdate(float pSecondsElapsed) {
if (mClean) {
mClean=false;
clean1();
}
super.onUpdate(pSecondsElapsed);
}
}
Комментариев нет:
Отправить комментарий