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

Author Topic: [Solved]Doubt in using getPosition()  (Read 2386 times)

0 Members and 1 Guest are viewing this topic.

The Illusionist Mirage

  • Full Member
  • ***
  • Posts: 115
  • My Life = Linux, C++ & Computers
    • View Profile
    • fleptic
    • Email
[Solved]Doubt in using getPosition()
« on: August 15, 2013, 05:48:08 pm »
Hello

Whenever we use getPosition() in a sf::RectangleShape object, what coordinates are returned?

For example, suppose we have the following rectangle, called sf::RectangleShape Rect1 and we call Rect1.getPosition(), what is returned?



Thanks
« Last Edit: August 15, 2013, 06:03:58 pm by The illusionist mirage »

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: Doubt in using getPosition()
« Reply #1 on: August 15, 2013, 05:56:37 pm »
Documentation, about Origin :

Quote
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

The Illusionist Mirage

  • Full Member
  • ***
  • Posts: 115
  • My Life = Linux, C++ & Computers
    • View Profile
    • fleptic
    • Email
Re: Doubt in using getPosition()
« Reply #2 on: August 15, 2013, 06:00:27 pm »
Documentation, about Origin :

Quote
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

So in the above case Rect1.getPosition() returns 125, 130?

Thanks for the help

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Doubt in using getPosition()
« Reply #3 on: August 15, 2013, 06:01:52 pm »
No.. it returns (100,100) as lo-x explained.. The top-left corner! :))

This is only the right answer if the origin is (0,0) as the default goes, though. As Lo-X also quoted :D

The Hatchet

  • Full Member
  • ***
  • Posts: 135
    • View Profile
    • Email
Re: Doubt in using getPosition()
« Reply #4 on: August 15, 2013, 06:02:18 pm »
The default origin is (0, 0) so the upper left corner of the rectangle.  you can change the origin with setOrigin()

The Illusionist Mirage

  • Full Member
  • ***
  • Posts: 115
  • My Life = Linux, C++ & Computers
    • View Profile
    • fleptic
    • Email
Re: Doubt in using getPosition()
« Reply #5 on: August 15, 2013, 06:03:22 pm »
No.. it returns (100,100) as lo-x explained.. The top-left corner! :))

This is only the right answer if the origin is (0,0) as the default goes, though. As Lo-X also quoted :D

Thanks! now it's totally clear! :D

 

anything