Pregunta

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);
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top