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

Author Topic: How would you go about translating a transformable ?  (Read 1048 times)

0 Members and 1 Guest are viewing this topic.

stavsen

  • Newbie
  • *
  • Posts: 5
    • View Profile
How would you go about translating a transformable ?
« 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 :)
« Last Edit: March 08, 2018, 10:46:06 pm by stavsen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: How would you go about translating a transformable ?
« Reply #1 on: March 08, 2018, 10:55:54 pm »
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.

Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything