Hello
I have made a custom mouse icon and I am using it through the methods - Render_window_name.setMouseCursorVisible(false)
and MouseSprite.setPosition(sf::Vector2f(sf::Mouse::getPosition(Render_window_name)));
I have also added a sound that is played everytime the user clicks the left button. Everything is smooth except that while I click the left button and hold it the sound keeps on playing. I want that it must be played only once when the left button is pressed, no matter for how much time I hold it.
How do I set up a sound using SFML so that it plays only once when the mouse is clicked.
Thanks
Use events (sf::Event::MouseButtonPressed) instead of real-time input (sf::Mouse::isButtonPressed()).
Yea, thanks, it worked beautifully. :)
And your position is wrong; use the sf::RenderWindow::map...() function to map correctly from pixel to world coordinates. Like this, your code won't break if you use a different view.
I am making a pong clone and just need the mouse for navigating through menu and stuff. So do you really want that I should not use MouseSprite.setPosition(sf::Vector2f(sf::Mouse::getPosition(Render_window_name)));