GameSalad

Accelerometer - Reversed Gravity When Upside Down?

I'm having a problem with using the Accelerometer; When the device orientation is is left landscape mode, the Accelerometer works normally (i.e. tilt the device to the left and it accelerates left), but if I rotate the device 180 degrees (making the device orientation right landscape) the actors accelerate in the direction opposite to the way the device is tilted...
Has anyone dealt with this before or have a fix? @Socks @Guru

Comments

  • RThurmanRThurman Posts: 2,760Member, Sous Chef, PRO

    @rainwaterstudios -- you can determine which way is 'down' by using the formula:
    vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)

  • rainwaterstudiosrainwaterstudios Posts: 101Member, PRO

    @RThurman said:
    @rainwaterstudios -- you can determine which way is 'down' by using the formula:
    vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)

    Thanks for the tip, could you elaborate? Where would the vectorToAngle function be implemented?

  • RThurmanRThurman Posts: 2,760Member, Sous Chef, PRO

    @rainwaterstudios said:

    Thanks for the tip, could you elaborate? Where would the vectorToAngle function be implemented?

    I guess I would need to know more about what you are trying to do.

    You can also test for device orientation:
    game.Screen.Device Orientation

    I believe it returns 1,2,3, or 4 for the different orientations.

Sign In or Register to comment.