我想建造什么;
应用程序始终处于横向模式(手机顶部左侧!)。
当用户翻转手机(在 Y 轴上,因此用户正在看手机的背面,屏幕在坐在桌子另一端的人面前)时,方向应该变为 Reversed Landscape。在这种情况下,正在显示的 TextView 将是正对着看屏幕的人。
然后,当用户翻转手机时,方向应该变回横向。
但是......(这里有一个问题......)当用户将手机转过 X 轴时(所以看着屏幕,顺时针转动它(couter),什么都不会发生。(在游戏中,这将是作弊)
我尝试使用 onSensorChanged,但它的行为不像我描述的那样。有什么想法吗?谢谢
public void onSensorChanged(SensorEvent event) {
TextView tv = (TextView) findViewById(R.id.TextView01);
tv.setText("0 : " + event.values[0] + "1 : " + event.values[1] + " -- 2 : " + event.values[2]);
if (event.values[1] < -6 || event.values[1] > 6) {
playfair();
return;
} else {if (event.values[1] > -6 || event.values[1] < 6){cheat = false;}}
if (event.values[0] < -8.5) {
if (state == PRE_ROUND)
startround();
} else {
if (state == SHOWING_OBJECT){
flipper.setInAnimation(inFromBottomAnimation(1));
flipper.setOutAnimation(outToTopAnimation(1));
flipper.setDisplayedChild(1);
state = PRE_ROUND;
}
}
}