I am using the sprite origin as x1 and y1
I then swipe down from sprite, either down to the right or left, then let go. On touch end when I let go I record x2 and y2.
I then apply impulse - angle(x1,y1,x2,y2)
When x2 is less than x1 (swiping down to the left) it works fine and shoots the sprite up to the right.
If I swipe down to the right and x2 ends up greater than x1, then the sprite fires off down to the right in opposite direction I wanted.
Please advise if my angle setting is wrong and what formula I should be using to calculate the angle.
Thanks for any replies.
Develop games in your browser. Powerful, performant & highly capable.
See this demo: