Permalink
Browse files

Bug 738361: Fix music fading bugs

  • Loading branch information...
1 parent 9514bef commit 4c23f09218ed745650c006dd182c1eae9a354206 @sork sork committed Mar 24, 2012
Showing with 15 additions and 3 deletions.
  1. +12 −2 client/js/audio.js
  2. +3 −1 client/js/game.js
View
@@ -150,6 +150,9 @@ define(['area'], function(Area) {
if(music) {
if(!this.isCurrentMusic(music)) {
+ if(this.currentMusic) {
+ this.fadeOutCurrentMusic();
+ }
this.playMusic(music);
}
} else {
@@ -184,6 +187,7 @@ define(['area'], function(Area) {
fadeOutMusic: function(music, ended_callback) {
var self = this;
if(music && !music.sound.fadingOut) {
+ this.clearFadeIn(music);
music.sound.fadingOut = setInterval(function() {
var step = 0.02;
volume = music.sound.volume - step;
@@ -211,8 +215,7 @@ define(['area'], function(Area) {
music.sound.volume = volume;
} else {
music.sound.volume = 1;
- clearInterval(music.sound.fadingIn);
- music.sound.fadingIn = null;
+ self.clearFadeIn(music);
}
}, 30);
}
@@ -224,6 +227,13 @@ define(['area'], function(Area) {
music.sound.fadingOut = null;
}
},
+
+ clearFadeIn: function(music) {
+ if(music.sound.fadingIn) {
+ clearInterval(music.sound.fadingIn);
+ music.sound.fadingIn = null;
+ }
+ },
fadeOutCurrentMusic : function() {
var self = this;
View
@@ -985,7 +985,9 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
self.audioManager.playSound("teleport");
}
- self.audioManager.fadeOutCurrentMusic();
+ if(!self.player.isDead) {
+ self.audioManager.updateMusic();
+ }
}
if(self.player.target instanceof Npc) {

0 comments on commit 4c23f09

Please sign in to comment.