我正在制作一个具有加速度计功能的游戏,因此每次我将设备向左转时,船都会向左倾斜,反之亦然,问题是船会自行向左移动这是我的代码
public void onSensorChanged(SensorEvent event){
if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
float x = event.values[0];
deltaX = xBefore-x;
xBefore = x;
if(deltaX>0){//move right
SFEngine.playerFlightAction = SFEngine.PLAYER_LEFT_BANK_1;
}else{//move left
SFEngine.playerFlightAction =SFEngine.PLAYER_RIGHT_BANK_1;
}
}
}