Question

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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top