In Pygame how would I define which sound I want to play in certain "if" events? I've been able to load them both in I just hit the issue of not playing either on demand. Thanks for helping me in advance.
Asked
Active
Viewed 61 times
0
-
What do you mean? Just make an if statement and set your sound to play nested within. – Malik Brahimi Mar 03 '15 at 22:29
-
I have currently got two if statements but when I try to use Pygame.mixer.music.play(1) it just takes the first song from the song list I made. – Mar 03 '15 at 22:33
-
You have to use a sound object. – Malik Brahimi Mar 03 '15 at 22:38
-
possible duplicate of [Add scrolling to a platformer in pygame](http://stackoverflow.com/questions/14354171/add-scrolling-to-a-platformer-in-pygame) – Kevin Panko Mar 03 '15 at 23:30
1 Answers
1
You need to use a sound object to play sounds.
if condition_one_true:
sound_one = Sound('sound1.mp3')
sound_one.play()
if condition_two_true:
sound_two= Sound('sound2.mp3')
sound_two.play()

Malik Brahimi
- 16,341
- 7
- 39
- 70