0
Можете ли вы сказать, где моя ошибка? В методе Destroy в строке 'PhysicsWorld.destroyBody (this.body)' выдается исключение. Я использую последнюю версию AndEngine и Box2D.AndEngine удаляет физическое тело с экрана
public class Asteroid extends Sprite
{
private PhysicsWorld physicsWorld;
private PhysicsConnector physicsConnector;
private Body body;
public Asteroid(float pX, float pY, ITextureRegion pTextureRegion, VertexBufferObjectManager pVertexBufferObjectManager, PhysicsWorld physicsWorld)
{
super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
this.physicsWorld = physicsWorld;
final FixtureDef mFixtureDef = PhysicsFactory.createFixtureDef(0, 0f, 0f);
mFixtureDef.isSensor = true;
this.body = PhysicsFactory.createCircleBody(physicsWorld, this, BodyDef.BodyType.DynamicBody, mFixtureDef);
this.physicsConnector = new PhysicsConnector(this, this.body, true, true);
physicsWorld.registerPhysicsConnector(this.physicsConnector);
this.body.setLinearVelocity(new Vector2(0, 10));
this.body.setUserData(this);
}
public void Destroy()
{
this.physicsWorld.unregisterPhysicsConnector(this.physicsConnector);
this.body.setActive(false);
physicsWorld.destroyBody(this.body); // throws Exception ???
this.detachSelf();
}
}