Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is there a a better way to move sprites?  (Read 1133 times)

0 Members and 1 Guest are viewing this topic.

jyugrace

  • Newbie
  • *
  • Posts: 1
    • View Profile
Is there a a better way to move sprites?
« on: April 27, 2014, 09:33:20 am »
In my program I'm moving a sprite using the .setPosition in a while loop. In the loop, each iteration redraws the sprite at a new position and then clears the previous iteration .draw, which effectively animates the movement of the sprite across the program. But is there a better way to move around sprites? I really feel like there must be something better. Any tips would be greatly appreciated, thanks!

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Is there a a better way to move sprites?
« Reply #1 on: April 27, 2014, 09:57:20 am »
sf::Sprite has a move-function, which moves your sprite by the given value in pixels.
Read the documentation, it helps a lot.
Failing to succeed does not mean failing to progress!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Is there a a better way to move sprites?
« Reply #2 on: April 27, 2014, 12:13:54 pm »
You clear, you update, you draw. What exactly do you think is wrong in this approach? That's what everybody does ;)
Laurent Gomila - SFML developer

 

anything