androidrotationscreentilt

Android App: How to get screen tilt?


I am coding an app for Android and I was wondering how to get the screen tilt? For example: If the user tilts the screen to the right, I want their character (in-game) to move to the right. If they tilt it to the left, I want the character in the game to move to the left. This is seen in Temple Run, where the guy is running and if you tilt your screen to the left he goes to the left and vice versa. Thanks.


Solution

  • What you want to say I think is not about titling screen but about getting the GPS coordination. This question has been asked again so I'll go ahead and post to relevant questions and see if the can help you.

    Get GPS Coordinates : Android

    How to get current location in Android

    My guess is that the Temple Run game checks the GPS coordination and depending on how the coordination have changed the game call's a certain method. Titling rotates the whole screen by 90 degrees not a part of it.

    If you still can't understand we are here to help you out.

    edit after snachmsm comment:

    Here there are detailed information for using the Accelerometer

    and an answer about using Gyroscope