SFML community forums
Help => Graphics => Topic started by: Dummie on March 21, 2008, 10:53:48 pm
-
Hey,
Currently I'm checking out the possibillities to rotate a sprite. It works very great, but I got a question. Why the degree get with every turn +/-360?
I was wondering very much when I made a debug output with GetRotation() and saw a very big or very small value instead of something like 127...
In addition to that I'd like to build something like this:
http://www.tonypa.pri.ee/tbw/tut20.html
Could somebody provide me a code example that calculate the values I have to pass to SetLeft() and SetTop() to get the same result as on the page I posted above?
Thanks in advance :) :) :)
PS: If I rotate the sprite do I have to call this code again?
Sprite.SetRotationCenter(Sprite.GetHeight() / 2, Sprite.GetWidth() / 2);
Or is it done by SFML already?
-
You only have to set the center once.
-
Thank you :)
But I still haven't a answer to my other question :)
Thanks in advance
-
Why the degree get with every turn +/-360?
Because there's no code to keep it in the range [0, 360] or [-180, 180] (or whatever you prefer). You can apply a modulo if you want to keep it in a specific range.
Maybe I'll have to do it on SFML side however, as accumulation with float numbers could cause a loss of precision.
-
Maybe I'll have to do it on SFML side however, as accumulation with float numbers could cause a loss of precision.
It actually do, i've encoutered the problem a couple of times.
-
Ok, rotations are now kept in the range [0, 360].