Rotate 2d sprite towards pointer
- by Phil
I'm using Crafty.js and am trying to point a sprite towards the mouse pointer.
I have a function for getting the degree between two points and I'm pretty sure it works mathematically (I have it under unit tests). At least it responds that the degree between { 0,0} and {1,1} is 45, which seems right.
However, when I set the sprite rotation to the returned degree, it's just wrong all the time. If I manually set it to 90, 45, etc, it gets the right direction..
I have a jsfiddle that shows what I've done so far.
Any ideas?