SFML community forums
Help => General => Topic started by: stavsen on March 08, 2018, 10:43:07 pm
-
Hi
I have a Node object that inherits from sf::Transformable
and im able to move, rotate and scale it perfectly.
I was just wondering if it was also possible to translate its position by a given length?
the documentation doesn't seem to show any 'translate()' function ?
Im not very strong with vector math so im sorry if this is very simple
Thanks :)
-
move() is your translate() function. If you want to translate from point A to point B, thus you move from x amount on the X-axis and y amount on the Y-axis to get to point B.
If you just have a distance, then you don't know where to go, because a distance doesn't define the direction. If you have the distance and an angle, then you can use trigonometry to calculate the point you want to go.
I won't explain you math, as this is not a math forum but the SFML forum, but here's a graphic that may or may not help you.
(https://i.imgur.com/12CvgoK.png)