Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:41:53+00:00 2026-05-24T19:41:53+00:00

My game uses the accelerometer, everything works fine but I noticed there is going

  • 0

My game uses the accelerometer, everything works fine but I noticed there is going to be a slight issue with some phones. The game forces the orientation to be landscape however some phones have a default screen orientation of landscape…

Right now I was always assuming the user was going to have to tilt their phone to see the game correctly, this would mean the accelerometer reading for the X axis would move the player in the Y and the Y reading would move the player in the X. With the phones that have a default landscape screen the X will correspond to the X in game and the Y for the Y in game (as they wont need to tilt their phones.)

My question is how do I handle this? I can adapt the code to invert the X and Y directions based on the phones orientation, so how would I get the current orientation of the phone programmatically? If there is a better way that would be great

Hope that makes sense

EDIT:

Actually would it be safe to assume that if the devices length is greater than its height the screen would be defaulted to landscape?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:41:53+00:00Added an answer on May 24, 2026 at 7:41 pm
    Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    int rotation = display.getRotation();
    

    from http://developer.android.com/reference/android/view/Display.html:

    public int getRotation ()

    Returns the rotation of the screen from its “natural” orientation. The
    returned value may be Surface.ROTATION_0 (no rotation),
    Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270.
    For example, if a device has a naturally tall screen, and the user has
    turned it on its side to go into a landscape orientation, the value
    returned here may be either Surface.ROTATION_90 or
    Surface.ROTATION_270 depending on the direction it was turned. The
    angle is the rotation of the drawn graphics on the screen, which is
    the opposite direction of the physical rotation of the device. For
    example, if the device is rotated 90 degrees counter-clockwise, to
    compensate rendering will be rotated by 90 degrees clockwise and thus
    the returned value here will be Surface.ROTATION_90.

    You’ll have to experiment with the devices to make sure android knows the “natural” orientation correctly. If so, then just check for ROTATION_90 (or ROTATION_270) to see if the device is on it’s side or not. If so, then switch x and y axis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building a card game and everything works fine when I write
I'm working on an iPhone game that uses the accelerometer for control. I don't
I have a game that uses the accelerometer to move the player. For this
I'm working on an iOS game that primarily uses accelerometer input. Previous programmers set
There are some other SO questions about concurrency but they don't quite address my
I have an iPhone game which I am porting to PC. The game uses
Possible Duplicate: c++ using too much cpu my game uses over 50% of cpu.
I'm writing a game which uses a border layout with a JPanel using BorderLayout.CENTER.
I'm working on a game that uses local area network. Like most of multiplayer
I've built a simple snake game that uses a Main class (this is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.