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

Author Topic: GetPosition()  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

Hazique35

  • Newbie
  • *
  • Posts: 16
    • View Profile
GetPosition()
« on: March 30, 2013, 01:06:44 pm »
This really confuses me. How is GetPosition used? Ive tried to use it but have failed. Can it be used for collisions:? Such as:
if (rectangle.getPosition() == rectangle2.getPosition() )
{
      cout<<"hit!";
}
(that didnt work by the way)
Could someone give me an example of how this is supposed to be used?

thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11004
    • View Profile
    • development blog
    • Email
Re: GetPosition()
« Reply #1 on: March 30, 2013, 01:38:23 pm »
You get the position as expected, but your rectangles mostly never will be at the exact same spot. So you should rather google for some collision detection, it's not the most easy topic. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hazique35

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: GetPosition()
« Reply #2 on: March 30, 2013, 01:52:32 pm »
ok.