Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Quick Tip: How to check when a sprite is clicked in SFML 2.0

I saw that this is a common problem this days . So, this is just a Function that returns true when a Sprite is clicked , even if the window is moved. You can integrate this function in any project you want.

Thanks and Enjoy!

bool lf_bCheckForMouseTrigger(sf::Sprite &av_Sprite, sf::RenderWindow &av_Window)
{
     
    int mouseX = sf::Mouse::getPosition().x;
    int mouseY = sf::Mouse::getPosition().y;
     
    sf::Vector2i windowPosition = av_Window.getPosition();
 
    if(mouseX > av_Sprite.getPosition().x + windowPosition.x && mouseX  av_Sprite.getPosition().y + windowPosition.y + 30  && mouseY 

Cya next time.



This post first appeared on HoriaCondrea, please read the originial post: here

Share the post

Quick Tip: How to check when a sprite is clicked in SFML 2.0

×

Subscribe to Horiacondrea

Get updates delivered right to your inbox!

Thank you for your subscription

×