SFML community forums
Help => Graphics => Topic started by: Kevin47 on September 22, 2010, 04:29:23 pm
-
Hello!
I'm trying to make graphical button (I read tutorials and I tested samples).
Here is my image:
(http://img245.imageshack.us/img245/8444/buttonhw.png)
Code example:
If you click left mouse button and mouse cursor X pos is 100-218 and Y pos is 100-161
{
do something
}
Can someone help? Thanks! :)
-
What exactly is the problem?
-
What exactly is the problem?
I don't know how to make this.
-
bool MouseOver(sf::Sprite &Sprite)//returns true if the mouse is over given sf::Sprite
{
float XPos = Sprite.GetPosition().x;//the x position
float YPos = Sprite.GetPosition().y;//the y position
float XSize = Sprite.GetSize().x;//the width
float YSize = Sprite.GetSize().y;//the height
if(MouseX >= XPos && MouseX <= XPos+XSize && MouseY >= YPos && MouseY <= YPos+YSize)
return true;
else
return false;
}