SFML community forums

Help => Graphics => Topic started by: player931402 on January 18, 2012, 03:58:39 pm

Title: sf::Sprite -> Move and SetPosition
Post by: player931402 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?
Title: sf::Sprite -> Move and SetPosition
Post by: texus 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)
Title: sf::Sprite -> Move and SetPosition
Post by: player931402 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