Sorry if this is the wrong forum, I wasn't sure where to post this. I'm currently using SFML 2.1 and I am creating a user interface. For whatever reason, when I use sf::Clock (specifically clock.getElapsedTime()) it makes the if statement execute at random clicking intervals (it's applied to a button being clicked on.) Here's the if statement and relevant code:
bool back = isSpriteClicked(backButton, mouseCoords, mouse);
if (back == true && clock.getElapsedTime() >= sf::milliseconds(150))
{
backButton.setColor(sf::Color(200, 200, 200));
clock.restart();
scrollBar.setPosition(WINDOW_WIDTH - 49, 53);
reportPic.setPosition(270, 10);
choice = 0;
}
else if (back == false)
backButton.setColor(sf::Color(scrollArrowColor));
When I remove the time check, it executes perfectly. The reason I have it is because the "back" button is in the same place across all screen (which is normal) and if I don't have any delay, it will "back" out of multiple screens at once, which I'm trying to avoid, of course. The EXTREMELY strange thing is that same if statement works in 2 other places in my code (aside from the variables being different obviously.) Thanks for taking your time to help.