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

Author Topic: sf::View.get/setCoordinates()  (Read 2775 times)

0 Members and 1 Guest are viewing this topic.

Ich1994

  • Newbie
  • *
  • Posts: 2
    • View Profile
sf::View.get/setCoordinates()
« on: August 14, 2012, 03:21:54 am »
I would like to have the above mentioned methods.

It does not look good if i have to write something like this:
sf::Vector2i Coord=sf::Vector2i(myView.getCenter().x-myView.getSize().x/2,myView.getCenter().y-myView.getSize().y/2);
everytime i need to set or get the Top-Left Coordinates

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::View.get/setCoordinates()
« Reply #1 on: August 14, 2012, 08:18:06 am »
And why not:
sf::Vector2f Coord = myView.getCenter() - myView.getSize() / 2.f;
?

The origin of views is their center point. That's the most intuitive solution for 90% of use cases, so I won't change it just for you ;)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::View.get/setCoordinates()
« Reply #2 on: August 14, 2012, 08:23:31 am »
If you write the same code again and again, you have not understood an important point in programming. Write a global function that takes a view and returns its top-left coordinates.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ich1994

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: sf::View.get/setCoordinates()
« Reply #3 on: August 14, 2012, 06:12:27 pm »
And why not:
sf::Vector2f Coord = myView.getCenter() - myView.getSize() / 2.f;
?

Because i am new to SFML :D

 

anything