[英]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. 我正在创建一个使用加速度计在横向方向上进行X轴和Y轴运动的Android游戏。 The X-axis works as expected, however the Y-axis is causing an issue. X轴按预期工作,但是Y轴引起问题。
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. 为了使Y轴正常工作,Y轴必须为0(电话完全处于屏幕显示状态。)这是一个问题,因为我不希望用户弯腰手机才能正常播放。
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. 我试图通过获取Y轴方向的初始读数并从随后的Y轴读数中减去该值来纠正此问题,但是如果用户以-10开始游戏(手机屏幕直接面对它们),则手机将不会注册任何进一步向后倾斜。
Does anyone know a better way to handle this situation? 有谁知道更好的方法来处理这种情况? Thank you all for the help thus far! 谢谢大家到目前为止的帮助!
It's possible. 这是可能的。 Check out Allowing both landscape options and accelerometer with libgdx 签出同时使用libgdx的横向选项和加速度计
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.