Search code examples
androidaccelerometergame-physicsandroid-orientation

Android Game Programming -- Accelerometer vs. Compass


Hello StackOverflowers,

I am designing a game for Android where I plan on allowing the user to move in four different directions (up, down, left, and right). I would like to implement this using either Sensor.TYPE_ACCELEROMETER or Sensor.TYPE_ORIENTATION. If I am doing only the above-four-specified directions, is there an advantage to using Sensor.TYPE_ACCELEROMETER over Sensor.TYPE_ORIENTATION, or vice versa? Thanks in advance for your answers, help, and suggestions.

Justin.


Solution

  • When you say "move" do you mean tilt or translate?

    Using the accelerometer and gyroscope simultaneously should give the coverage of motion necessary to divine up,down,left,right. So use TYPE_ACCELEROMETER and TYPE_GYROSCOPE in a coordinated fashion.

    Sensor.TYPE_ORIENTATION is deprecated, I believe.

    I caveat this answer by saying I am primarily an iOS developer, only have a couple of finished Android projects and both are NDK based....