I can not find anything else about this strange bug, leaving me to believe I've stumbled upon something weird. I use a simple function comparing a sprite's position to the mouse to see if the mouse is hovering over the sprite. I've found that when you resize the window, the images stretch. I do like this feature, but what I do not like about it is, the sprite's original x,y are kept and it's not updated when the window is stretched. I am getting the mouses coords relative to the window too. Here's my code for detecting if the mouse is over the sprite. Please correct any errors you see, or give me tips.
I create a RenderWindow object:
sf::RenderWindow myWindow;
I create a simple function that returns true if the mouse is within the sprite's x and y boundries and its width + height.
bool isMouseOverSprite(const sf::RenderWindow& myWindow, const sf::Sprite& Sprite)
{
return (sf::Mouse::getPosition(myWindow).x < (Sprite.getPosition().x + Sprite.getGlobalBounds().width)) && (Sprite.getPosition().x < sf::Mouse::getPosition(myWindow).x) &&
(sf::Mouse::getPosition(myWindow).y < (Sprite.getPosition().y + Sprite.getGlobalBounds().height)) && (Sprite.getPosition().y < sf::Mouse::getPosition(myWindow).y);
}
Maybe I missed something in the forums or documentation or tutorials, but this code works when my window is set to a small 900x600 window. I realize this is an odd resolution and I don't plan on keeping it. I'm in very early testing stages of a lot of things at this point. The point is, when I resize the window, the sprites report their original x,y coordinates while the mouse reports its NEW x,y coordinates.
What I'm trying to say is, the sprite class accounts for stretching, the mouse class does not. Maybe this is intended, I do not know. I may have missed a detail reading up for this issue.