Music soundtrack fades out at end of game
authorTJ <git@iam.tj>
Sat, 9 Nov 2013 21:34:26 +0000 (21:34 +0000)
committerTJ <git@iam.tj>
Sat, 9 Nov 2013 21:34:26 +0000 (21:34 +0000)
pygame-scroller.py

index 3a363b4..30c1ae4 100755 (executable)
@@ -42,6 +42,11 @@ class Channel:
    self.channel.queue(sound)
  def get_queue(self):
   return self.channel.get_queue() if self.channel != None else None
+ def fadeout(self, time):
+  if self.channel == None:
+   pygame.mixer.music.fadeout(time)
+  else:
+   self.channel.fadeout(time)
  def play(self, sound, loops=0, maxtime=0, fade_ms=0):
   if self.channel != None:
    # allow 'sound' to be a path string or an object
@@ -184,6 +189,7 @@ while (myGame.play):
    # volume up
    myGame.soundtrack.up()
 
+myGame.soundtrack.fadeout(10000)
 time.sleep(10)
 pygame.display.quit()
 exit(0)