Android的方向传感器为不同的设备有什么不同? [英] Android Orientation Sensor Different for Different Devices?

查看:235
本文介绍了Android的方向传感器为不同的设备有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发使用了方向感应器来获得设备的旋转的的Andr​​oid游戏(滚动球)。我有我的测试应用两个设备,一个是三星杨维龙(电话),另一个是华硕Eee Pad TF101变压器(片)。

I'm developing an Android game that uses the orientation sensor to get the rotation of the device (to roll a ball). I have two devices that I test apps on, one is a Samsung Infuse (phone) and the other is an Asus Eee Pad Transformer TF101 (tablet).

该应用程序在两台设备上运行的景观。问题是,在Eee Pad的,方向与设备侧身(横向模式),而杨维龙措施测量直立(纵向)无论我做什么。这使得如此球的时候我我倾斜杨维龙左侧左侧移动,但是当我倾斜的Eee Pad左侧,球或上下移动。

The app runs in landscape on both devices. The problem is that on the Eee Pad, the orientation is measured with the device sideways (landscape mode) while the Infuse measures in upright (portrait) no matter what I do. This makes is so the ball moves left when I tilt my Infuse left, but when I tilt the Eee Pad left, the ball moves up or down.

我可以切换的取向的角度,所以它们移动球的其他方式,但它仅适用于一个或另一个在一个时间。任何想法我怎么能解决这个问题?

I can switch the orientation angles, so they move the ball the other way, but it only works for one or the other at a time. Any ideas how I could fix this?

是的,我现在用的是德precated TYPE_ORIENTATION,而不是getOrientation()方法。我尝试设置它,但我从来没有得到它正常工作,它总是吐出来很奇怪的价值观,所以我坚持去precated之一。将切换解决这个问题呢?如果是这样,有人可以联系我的资源来实现这一点?

Yes, I am using the deprecated TYPE_ORIENTATION, and not the getOrientation() method. I tried setting it up, but I never got it working correctly and it always spat out really weird values, so I stuck to the deprecated one. Would switching over fix this at all? If so, can someone link me to resources to implement this?

推荐答案

谷歌的文档清楚地表明了的传感器坐标系是相对于设备的的默认的方向。这说明提到了 getRotation() remapCoordinateSystem()召唤你可以用它来适当调整。

Google's docs make it clear that the sensor coordinate system is relative to the default orientation of the device. That description mentions the getRotation() and remapCoordinateSystem() calls you can use to adjust appropriately.

这篇关于Android的方向传感器为不同的设备有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆