SFML community forums

Help => Graphics => Topic started by: JM1082 on March 21, 2012, 02:33:41 pm

Title: Sprite.GetSize() advice needed...
Post by: JM1082 on March 21, 2012, 02:33:41 pm
Hi all,

I want to use the Sprite.GetSize() function on a sprite I've loaded into my RenderWindow.

My sprite is called buttonTwo, so when I try to:

Code: [Select]
cout << buttonTwo.GetSize() << endl;

OR

simply calling buttonTwo.GetSize() on its own...

I'm expecting something alond the lines of pixel ranges, i.e. 1024, 600...

Instead I get a bunch of warnings talking about a Vector2f...

So I tried creating a float variable, capturing the function output into it, then displaying it:

Code: [Select]
float size = buttonTwo.GetSize();
cout << size << endl;


But still no luck...

Any suggestions would be much appreciated.
Title: Sprite.GetSize() advice needed...
Post by: dotty on March 21, 2012, 02:43:10 pm
you using 2.0? Because getSize does't exist.

In 1.6 GetSize() returns a Vector2f. A Vector2f has an x and y, so you'll need to use

buttonTwo.GetSize().x or buttonTwo.GetSize().y
Title: Re: Sprite.GetSize() advice needed...
Post by: JM1082 on March 29, 2012, 06:49:56 pm
Thanks!  That's a great help!!!  ^^