Your code works... somewhat.. Only about a quarter of the button sprite I'm loading actually responds. Heres my modified code:
bool Button::isSpriteClicked(Sprite& sprite, RenderWindow* window) {
sf::IntRect rect(sprite.getPosition().x, sprite.getPosition().y, sprite.getGlobalBounds().width, sprite.getGlobalBounds().height);
if (rect.contains(Mouse::getPosition()) && (Mouse::isButtonPressed(Mouse::Left))) {
TextureManager tm;
Sprite sprite1;
sprite1.setTexture(tm.getTexture("cute_image.jpg"));
tm.drawSprite(sprite1, *window);
return true;
}
return false;
}
Pretty much, what I want is if the mouse is in the area AND clicking then using my texture manager I coded draw another image as long as the user is holding down the left mouse button. Like I said before, only about half of it works because when I click in the left quarter of the button sprite, it will respond perfectly. But anywhere else on the sprite? It won't do a thing. I don't know why it's doing this....