0

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?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
AdamC
  • 16,087
  • 8
  • 51
  • 67
  • 2
    Don't know if they're exact duplicates, but these should help: http://stackoverflow.com/questions/1059839/how-to-build-a-sensor-simulator-for-android http://stackoverflow.com/questions/198982/how-to-do-gesture-recognition-using-accelerometers – Sasha Chedygov Jul 10 '09 at 22:03

2 Answers2

7

AndEngine supports easy access to the acelerometer

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

this.enableAccelerometerSensor(this);

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

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

(Taken from: http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/PhysicsExample.java )

Best Regards,

Nicolas

Nicolas Gramlich
  • 2,790
  • 19
  • 19
  • There are lots of objects on my screen like (Ball, Sticks, Windows etc) but i want only sticks can be move using accelerometer. how can i do this? – Amit Thaper Apr 02 '12 at 05:21
1

I would recommend you to checkout this open sourced marble game. at google code.

kripto_ash
  • 919
  • 7
  • 14