Fix accelerometer processing

This commit is contained in:
Victor 2014-01-15 20:10:36 +02:00
parent 402178eefa
commit fcbb0aeb2c

View File

@ -3,6 +3,7 @@ package com.annimon.influencexxii;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Input.Peripheral; import com.badlogic.gdx.Input.Peripheral;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
/** /**
@ -74,15 +75,8 @@ public class Pointer {
} }
private void controlByAccelerometer() { private void controlByAccelerometer() {
int orientation = Gdx.input.getRotation(); float ax = Gdx.input.getAccelerometerY();
float ax = Gdx.input.getAccelerometerX(); float ay = -Gdx.input.getAccelerometerX();
float ay = Gdx.input.getAccelerometerY();
if (orientation == 90) {
float temp = ax;
ax = ay;
ay = -temp;
}
x += ax * screenWidth / 500f; x += ax * screenWidth / 500f;
y += ay * screenHeight / 500f; y += ay * screenHeight / 500f;