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

Author Topic: [SFML2] SetX/SetY disappeared ?  (Read 2586 times)

0 Members and 1 Guest are viewing this topic.

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
[SFML2] SetX/SetY disappeared ?
« on: August 06, 2012, 12:39:36 pm »
Hi

I've downloaded the latest SFML2 RC build and I cannot find these useful functions, are they hidden somewhere or temporarily disabled for some reason?

I was a good user of them, I think having "s.SetPosition(s.GetPosition().x,y)" everywhere I need to set only X or Y position of an object is not clean and make the code harder to read (and probably a little bit slower due to the getposition() call)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: [SFML2] SetX/SetY disappeared ?
« Reply #1 on: August 06, 2012, 12:45:39 pm »
Yes they do not exist anymore as the documentation would also show. The design decision is a good thing though, it keeps the interface clean. If you have to change often the position, it's adivced to use a vecotr to make the position change and then just hand that over to sprite.
About performance you don't need to fear anything. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: [SFML2] SetX/SetY disappeared ?
« Reply #2 on: August 06, 2012, 01:07:57 pm »
Thank you

For the vector trick, do you mean I have to use a vector to store/modify coordinates, then put "s.setPosition(vector[0],vector[1])" in the main loop ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: [SFML2] SetX/SetY disappeared ?
« Reply #3 on: August 06, 2012, 01:32:58 pm »
Hehe, no I was refering to sf::Vector2 which holds the x and y coordinate and every size-function has an argument list for vector so you can just use .setPosition(myVec).
If you don't use already vecotrs for your entities/objects then you maybe need to rethink your design. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
Re: [SFML2] SetX/SetY disappeared ?
« Reply #4 on: August 06, 2012, 04:20:52 pm »
Agree with eXpl0it3r here. I used to be pretty much seperate X/Y mindset, but vectors are so much cleaner.
{much better code}