Hello. I make a button:
sf::RectangleShape button1(sf::Vector2f(250, 70));
button1.setPosition(sf::Vector2f(350, 200));
And now i need do somethink if player pressed on this button:
if (menu == 0) {
if (sf::Mouse::getPosition().x > 250 && sf::Mouse::getPosition().x < 600 &&
sf::Mouse::getPosition().y > 200 && sf::Mouse::getPosition().y < 270) {
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) menu = 1;
}
but menu = 1 if i pressed in another place (not on button1). Can someone explain me why?