Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: play 3 times sound buffer  (Read 2636 times)

0 Members and 2 Guests are viewing this topic.

molo32

  • Newbie
  • *
  • Posts: 1
    • View Profile
play 3 times sound buffer
« on: July 08, 2018, 09:03:15 pm »
pressing the f key should play the buffer. Then when you finish playing, increase again "i" and play again until "i" equals 3

but when pressing f only plays once, what is the problem?
      
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F)) {

         for (int i = 0; i < 3; i++)
         {
sound.setBuffer(buffer2);

sound.play();
}

   }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: play 3 times sound buffer
« Reply #1 on: July 09, 2018, 07:45:43 am »
Quote
Then when you finish playing
I can't see that condition in your code. All you do is to play the sound 3 times without waiting between each iteration, so you can only hear the last one.
Laurent Gomila - SFML developer

 

anything