• Advertisement
Sign in to follow this  

sf::Mouse::isButtonPressed issues

This topic is 1740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am working on a menu for my game and the buttons only activate when clicking in specific areas such as the middle bottom and the middle left side.

 

 

 
bool Aliens::Button::HandleEvents(sf::Event Event){
 
float MouseX = Event.mouseMove.x;
float MouseY = Event.mouseMove.y;
 
if(Event.type == sf::Event::MouseMoved){
 
if((MouseX >= mButtonSprite.getPosition().x) && (MouseX <= mButtonSprite.getPosition().x + mButtonBox.x) &&
(MouseY >= mButtonSprite.getPosition().y) && (MouseY <= mButtonSprite.getPosition().y + mButtonBox.y)){
 
mButtonSprite.setTexture(mMouseOverTexture);
 
if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) return true;
}
 
else mButtonSprite.setTexture(mNormalTexture);
}
 
return false;
}

 

 

Thanks for any help.

Edited by Crusable

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement