Accelerometer considers orientation

This commit is contained in:
Victor 2014-01-15 00:23:21 +02:00
parent 9a53f5faad
commit 7aef2c15ce

View File

@ -64,9 +64,16 @@ public class Pointer {
} }
private void controlByAccelerometer() { private void controlByAccelerometer() {
int orientation = Gdx.input.getRotation();
float ax = Gdx.input.getAccelerometerX(); float ax = Gdx.input.getAccelerometerX();
float ay = Gdx.input.getAccelerometerY(); 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;
validatePosition(); validatePosition();