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

Author Topic: sf::Sprite -> Move and SetPosition  (Read 8530 times)

0 Members and 1 Guest are viewing this topic.

player931402

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
sf::Sprite -> Move and SetPosition
« on: January 18, 2012, 03:58:39 pm »
what are the differences and when to use the first than the second ( or the second then first ) in my game loop?

texus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
    • TGUI
    • Email
sf::Sprite -> Move and SetPosition
« Reply #1 on: January 18, 2012, 04:15:51 pm »
SetPosition will change the position to the passed value, so SetPosition(20, 20) will put the sprite on position (20, 20).
Move will do exactly what the name suggests, move the sprite. If before the position was set to e.g. (60, 60) and you would call Move(20, 20) then the new position will be (80, 80).

So usually you will be using SetPosition and to change the position later when e.g. moving an object on the screen you can use Move.
So Move(x, y) is just to make this line more simple: SetPosition( GetPosition().x + x, GetPosition().y + y)
TGUI: C++ SFML GUI

player931402

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
sf::Sprite -> Move and SetPosition
« Reply #2 on: January 18, 2012, 04:20:08 pm »
Quote from: "texus"
SetPosition will change the position to the passed value, so SetPosition(20, 20) will put the sprite on position (20, 20).
Move will do exactly what the name suggests, move the sprite. If before the position was set to e.g. (60, 60) and you would call Move(20, 20) then the new position will be (80, 80).

So usually you will be using SetPosition and to change the position later when e.g. moving an object on the screen you can use Move.
So Move(x, y) is just to make this line more simple: SetPosition( GetPosition().x + x, GetPosition().y + y)



thanks, I thought that there were differences much more complicated

 

anything