1
General / Smooth rotation of a sprite
« on: November 30, 2018, 11:51:06 am »
Let's say that I have a sprite and with code shown below I obtained a rotation angle:
rotation = (atan2f(dy, dx)) * 180 / 3.14159265;
How do I rotate a sprite smoothly with angle I have in "rotation"? I tried something like this but it didn't work:
for (int i = 0; i < rotation + 180; i++)
sprite.setRotation(i);
rotation = (atan2f(dy, dx)) * 180 / 3.14159265;
How do I rotate a sprite smoothly with angle I have in "rotation"? I tried something like this but it didn't work:
for (int i = 0; i < rotation + 180; i++)
sprite.setRotation(i);