Android Accelerometer For Gaming


I'm designing a game for Android and I would like to use the accelerometer for some aspects of control. Has anyone come across a tutorial or example for something like this?

Best Solution

AndEngine supports easy access to the acelerometer

You call this method to enable the Accelerometer with a listener:


and this is how you react on changes of the accelerometer:

public void onAccelerometerChanged(final AccelerometerData pAccelerometerData) {
    this.mPhysicsWorld.setGravity(new Vector2(pAccelerometerData.getY(), pAccelerometerData.getX()));

(Taken from: )

Best Regards,