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

Author Topic: Why getOrigin() doesnt return current position of object  (Read 3428 times)

0 Members and 1 Guest are viewing this topic.

kameleo327

  • Newbie
  • *
  • Posts: 2
    • View Profile
Why getOrigin() doesnt return current position of object
« on: January 07, 2019, 11:14:53 pm »
Like in topic,
I used getOrigin() to center begin and end of line in rect when it is inside rectangle area to .
I want to get origin of rectangle with getOrigin(), but why it doesnt return current value of origin.
Why getPosition do it ?

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Why getOrigin() doesnt return current position of object
« Reply #1 on: January 08, 2019, 07:39:46 am »
You seem to be confusing get functions and set functions. You can consult the official tutorials for examples:

https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php

kameleo327

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Why getOrigin() doesnt return current position of object
« Reply #2 on: January 09, 2019, 09:49:35 pm »
No, i know what is setOrigin and getOrigin,
Why getOrigin after setOrigin and moving object doesnt return current pos of origin?

AlejandroCoria

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • alejandrocoria.games
    • Email
Re: Why getOrigin() doesnt return current position of object
« Reply #3 on: January 09, 2019, 10:07:23 pm »
Moving an object does not modify its origin (which is in local coordinates).

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Why getOrigin() doesnt return current position of object
« Reply #4 on: January 09, 2019, 10:12:43 pm »
No, i know what is setOrigin and getOrigin,
Why getOrigin after setOrigin and moving object doesnt return current pos of origin?

Because getOrigin returns origin. If you have a (50, 50) sized rectangle and setOrigin(25, 25) to place the origin at the center of the rectangle, and then position the rectangle at (1000, 1000) world coordinates, getOrigin would return (25, 25) and getPosition would return (1000,1000). What you are doing by setting origin is changing which pixel of the rectangle will be "sitting on" (1000, 1000).

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Why getOrigin() doesnt return current position of object
« Reply #5 on: January 20, 2019, 11:12:47 pm »
Just wanted to add that getPosition() actually returns the global location of the object's origin.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*