If you have a sprite position: S = (Sx, Sy) and cursor position C = (Cx, Cy)
You can calculate the angle between the vector
= (Cx - Sx, Cy - Sy) and the unit vector, for example
= (1, 0, 0).
To calculate the angle, you can use cross product :

And then:

then you calculate the angle:

Finally, you rotate your sprite:
Sprite.SetRotation(alpha); //alpha in degree
source
share