Skip to content

Commit

Permalink
Bug 738361: Fix music fading bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sork committed Mar 24, 2012
1 parent 9514bef commit 4c23f09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions client/js/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ define(['area'], function(Area) {

if(music) {
if(!this.isCurrentMusic(music)) {
if(this.currentMusic) {
this.fadeOutCurrentMusic();
}
this.playMusic(music);
}
} else {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion client/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4c23f09

Please sign in to comment.