0
votes

I have the following code

playerPosition.x += acceleration.x * 10;
playerPosition.y += acceleration.y * 20;

acceleration currently works, I would like to detect if the player should move backwards(y decreasing) and if so change it to

playerPosition.y += acceleration.y * 10;

How does one detect if acceleration from the accelerometer is negative?

How does one retrieve the direction of the movement? left right etc?

1

1 Answers

2
votes

You just compare the acceleration with 0

acceleration.y < 0.0

or

acceleration.y > 0.0

There is a free app iSimulate where you can see what values accelerometer outputs.