Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

sf::Mouse::isButtonPressed issues

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Crusable   Members   

594
Like
0Likes
Like

Posted 18 April 2013 - 11:07 PM

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, 18 April 2013 - 11:09 PM.


#2 Crusable   Members   

594
Like
0Likes
Like

Posted 18 April 2013 - 11:25 PM

Never mind, I am a dumbass. I fixed it, sorry for wasting your time.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.