SFML community forums
Help => Graphics => Topic started by: totalwar235 on February 17, 2011, 11:06:16 pm
-
i want to create roll over images and i have found a way to do this with two "for" functions. is there a built in way to compare the location of a sprite and a mouse?
i only ask because checking the majority of the screen every time the screen refreshes is a waste of ram.
-
Hello,
you can use something like this :
if (mySprite.GetSubRect().Contains(mousePos.x, mousePos.y)
{
//...
}
-
Thanks for that idea. I had no clue GetSubReact even existed
-
I may be incorrect but I think you will have to offset the subrect with the sprites position for this to work. The sprite's subrect is only relative to itself, not the world/screen.
-
I may be incorrect but I think you will have to offset the subrect with the sprites position for this to work. The sprite's subrect is only relative to itself, not the world/screen.
do you know how to do that?
-
There's not only the position to take in account, but the rotation and scale as well. The TransformToGlobal function is your friend ;)