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

Author Topic: [Solved]Sprite positions  (Read 1811 times)

0 Members and 1 Guest are viewing this topic.

Hellgast23

  • Newbie
  • *
  • Posts: 6
    • View Profile
[Solved]Sprite positions
« on: February 09, 2013, 05:47:18 pm »
The only was I know on how to get a position of a sprite is by using sprite.GetPosition() wich returns a vector.
But lets say you wanne use an "if" function to do something when the X-Coordinates of a sprite are higher then a giving amount.
How could you do that? Atm I tried some stuff, but it keeps giving me errors... (The vectors kinda confuse me)

thanks for reading,
greetz,
Hellgast
« Last Edit: February 09, 2013, 06:27:01 pm by Hellgast23 »

Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
Re: Sprite positions
« Reply #1 on: February 09, 2013, 06:15:32 pm »
a vector contains a public member variable called x and y, to access public members, use the '.' operater, just like you do with public functions

sf::Vector2<float> Vec(-1,-1);
if (Vec.x <= 0){
   // do stuff
}
 
Long live rapid project development! -- Kestrel3D Game-Engine nearing completion

Hellgast23

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite positions
« Reply #2 on: February 09, 2013, 06:26:48 pm »
aa, that is exactly what I was looking for!
Thanks a lot!