1

I made this method which gets executed more than once and my problem is that for each call the music starts again. Is there a way to let the music plays and avoid that in the next call it get played again?

def schermataSconfitta(event):
   global puntatoreSchermata

   stampaImpiccato()
   stampaLettereIndovinate()
   stampaLettereSbagliate()

   schermata.blit(testoSchermata["lose message"]("Game Over. The word was '" + ''.join(parolaCasuale) + "'", 1, nero),(100,50))
   schermata.blit(testoSchermata["enter"]("Press SPACE to continue...", 1, nero),(100,100))

   pygame.mixer.music.load("Suoni/gameover.mid")
   pygame.mixer.music.set_volume(0.2)
   pygame.mixer.music.play(999)

   if event.type == pygame.KEYDOWN:
       if event.key == pygame.K_SPACE:
           puntatoreSchermata = stringheSchermata["playAgain"]
double-beep
  • 5,031
  • 17
  • 33
  • 41
Babbara
  • 448
  • 1
  • 6
  • 21
  • You can manage a state if the music is being played now. Have a look at this [answer](https://stackoverflow.com/a/8416666/4636715), it also avoids the caveat `pygame.mixer.music.get_busy()` emerges apparently. – vahdet Mar 01 '19 at 14:29

0 Answers0