0

I've got an XNA Windows Phone Game and you move a sprite with the accelerometer

My problem is that I can't figure out how to make the sprite face the direction it is moving. So far this is my code:

        arrowPos.Y += -accelState.X*10; 
        arrowPos.X += -accelState.Y*10;

        rotation = -(float)Math.Atan2(arrowPos.Y, arrowPos.X);
ChappieZ
  • 15
  • 1
  • 5

1 Answers1

0

Your current rotation calculation uses the current position of the sprite - the sprite may be in that position whether it is moving north or west.

Try using the accelState.X and accelState.Y values instead.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72