1

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.

2 Answers2

2

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

Community
  • 1
  • 1
We're All Mad Here
  • 1,544
  • 3
  • 18
  • 46
2

maybe use Accelerometer or Gyroscope? check doc here

snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Carmen Oct 11 '15 at 17:10
  • right, but question is not so precise (no code), so I've decided to put link only leting user pick own method/module – snachmsm Oct 12 '15 at 06:58
  • then it is better to add this as a comment to the question, not as an answer – Carmen Oct 13 '15 at 13:49