I'm using AndEngine and Box2d to develop a game. I'm applying a force to a body to keep it "aloft" equal to that of gravity. I have the scene set up so that:
public void onAccelerationChanged(final AccelerationData pAccelerationData) {
gravity = Vector2Pool.obtain(pAccelerationData.getX(), pAccelerationData.getY());
this.mPhysicsWorld.setGravity(gravity);
Vector2Pool.recycle(gravity);
}
Now I need to set my force applied:
body.applyForce(new Vector2(0,-*gravity*), new Vector2(body.getWorldCenter()));
How do I get the value of the gravity so that I can apply it as a force when the screen is tilted?