SFML community forums
Help => Audio => Topic started by: Ranzini on March 13, 2023, 02:14:22 pm
-
So i want a Sound to play, the moment the button is pressed.
With:
if (Keyboard::isKeyPressed(Keyboard::Space))
the sound playes the moment i let go of the button.
Thanks in advance
-
...restarts it from beginning if it was it already playing
Don't call play() if it's already playing, you won't hear anything if you restart the sound every frame.
May want to use an event like the KeyPressed Event (https://www.sfml-dev.org/tutorials/2.5/window-events.php#the-keypressed-and-keyreleased-events) instead.