Accelerometer considers orientation
This commit is contained in:
parent
9a53f5faad
commit
7aef2c15ce
@ -64,9 +64,16 @@ public class Pointer {
|
||||
}
|
||||
|
||||
private void controlByAccelerometer() {
|
||||
int orientation = Gdx.input.getRotation();
|
||||
float ax = Gdx.input.getAccelerometerX();
|
||||
float ay = Gdx.input.getAccelerometerY();
|
||||
|
||||
if (orientation == 90) {
|
||||
float temp = ax;
|
||||
ax = ay;
|
||||
ay = -temp;
|
||||
}
|
||||
|
||||
x += ax * screenWidth / 500f;
|
||||
y += ay * screenHeight / 500f;
|
||||
validatePosition();
|
||||
|
Loading…
Reference in New Issue
Block a user