SFML rotation of sprite with small steps

Mar 30, 2020 at 2:01pm
Hello everyone. I want to rotate a sprite with small step sizes.

I do not want to write directly as:

 
sprite.setRotation(90);


I want to do it with 1 degree increment in every step. Therefore, the sprite should not be seen as just 90 degree rotation. It should be seen as continuous change in rotation.

How do I implement that?
Mar 30, 2020 at 2:06pm
Utku wrote:
Hello everyone. I want to rotate a sprite with small step sizes.

I do not want to write directly as:

sprite.setRotation(90);

I want to do it with 1 degree increment in every step. Therefore, the sprite should not be seen as just 90 degree rotation. It should be seen as continuous change in rotation.

How do I implement that?

I've never used SFML, but what's wrong with sprite.setRotation(1); ?
Last edited on Mar 30, 2020 at 2:08pm
Mar 30, 2020 at 2:42pm
I guess what I would do would be to look up how to setup a timer event using SFML, make that timer fire - say 20 times a second, and attach an event handler to that timer to bump the rotation by +1 degree each time it is called.

Mar 30, 2020 at 2:56pm
@MikeyBoy,

sprite.setRotation(1); rotates only 1 degree. It happens only one time.


Mar 30, 2020 at 3:19pm
So... do it as many times as you need. What's the problem?
Mar 30, 2020 at 5:16pm
It should be seen as continuous change in rotation.

Every game frame update you call the sprite's rotation member function to change its orientation. If your frame rate is enough to be seen as continuous motion, the sprite will appear to be in continual rotation.

Your frame rate and the apparent speed of the sprite's rotation will dictate the degree of change from frame to frame.
Topic archived. No new replies allowed.