SFML community forums

Help => Graphics => Topic started by: MaZy on January 30, 2010, 06:41:55 pm

Title: can't get it work SubRect
Post by: MaZy on January 30, 2010, 06:41:55 pm
Hi, guys.
I want a mouseover + click script. I did and its working well. But if my sprites moves like 5 float right then subrect has same value. So i have read here i have to calculate it new.

I did that like:
Code: [Select]

if (RightKeyDown)
{
Player1.Move(5,0);
Player1.SetSubRect( sf::IntRect(Player1.GetPosition().x, Player1.GetPosition().y, Player1.GetPosition().x+50, Player1.GetPosition().y+50));
}


Are there wrongs?
Because click is working perfectly, but it lost their white color texture.

Screenshots to know what i mean:

(http://web1.bravo939.server4you.de/s/sfml/subrect%20(2).PNG)
When i have clicked
(http://web1.bravo939.server4you.de/s/sfml/subrect%20(1).PNG)
After moving 5 floats right. You see red what i did. There should be white. And in the area of red (between white and red) my click and mouseover works.

EDIT: Btw no rlly white i know. Its more grey :D
Title: can't get it work SubRect
Post by: Laurent on January 30, 2010, 06:59:14 pm
The subrect is the rectangle of the source image displayed by the sprite. You don't have to change it when you move your sprite.