1
General / Problems with clickable sprites
« on: May 04, 2015, 11:35:13 pm »
Hello, I want to make a sprite clickable, but when I use the code below, I never have to lift the mouse to navigate. Should I use sf::Event::mouseButtonReleased instead, and can you give an example?
sf::FloatRect bounds = sprite.getGlobalBounds();
sf::Vector2f mouse = Win.mapPixelToCoords(sf::Mouse::getPosition(Win));
if (bounds.contains(mouse) && sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
// Stuff happens.
}
sf::Vector2f mouse = Win.mapPixelToCoords(sf::Mouse::getPosition(Win));
if (bounds.contains(mouse) && sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
// Stuff happens.
}