SFML community forums
Help => Graphics => Topic started by: woskaz0n on December 23, 2008, 10:42:17 pm
-
Hi everybody,
I want to find out if my mouse is about an area or an object (with other words, a sprite :) ).
(this sprites are not made by myself!!!)
(http://img389.imageshack.us/img389/5359/unbenannt1kopiefh1.jpg)
An example: Here the mouse can be about the Tile 1, 2 or about the empty space... the thing that could make it a bit different is, that I don“t want to use fix coordinates in my source, like
(Cursor.GetPosition().x >= 200)
So, I tried a few things, but without any succes^^
if((Cursor.GetPosition().x == Sprite1.GetPosition().x) && (Cursor.GetPosition().y == Sprite1.GetPosition().y))
Why does it not work?
Thanks in advance!
-
With your condition, you need to point your mouse exactly on the point (Sprite1.GetPosition().x;Sprite1.GetPosition().y).
--> if (mouse.x >= sprite.x && mouse.x <= sprite.x + sprite.width && mouse.y >= sprite.y && mouse.y <= sprite.y + sprite.height)