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

Author Topic: can't get it work SubRect  (Read 1302 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 7
    • View Profile
can't get it work SubRect
« 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.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:

When i have clicked

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


  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
can't get it work SubRect
« Reply #1 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.
Laurent Gomila - SFML developer