简体   繁体   中英

LibGDX/Android development: Setting default orientation for accelerometer

I am creating an Android game that uses the accelerometer for X-axis and Y-axis movement in landscape orientation. The X-axis works as expected, however the Y-axis is causing an issue.

For the Y-axis to work properly, the Y-axis needs to be at 0 (The phone is perfectly screen-up.) This is an issue because I don't expect users to be hunched over their phones to play properly.

I attempted to correct this by taking the initial reading of the Y-axis orientation and subtracting that from the following Y-axis readings, but if the user begins the game at -10 (Phone screen directly facing them) the phone will not register any further tilting back.

Does anyone know a better way to handle this situation? Thank you all for the help thus far!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM