技能支持两个配音

This commit is contained in:
libccy 2015-05-16 19:22:27 +08:00
parent 721b176284
commit de19e68f1c
1 changed files with 22 additions and 13 deletions

View File

@ -1290,7 +1290,7 @@ window.play={};
game.playAudio('skill',event.skill); game.playAudio('skill',event.skill);
} }
else if(lib.config.background_ogg){ else if(lib.config.background_ogg){
game.playAudio('skill',event.skill); game.playSkillAudio(event.skill);
} }
} }
if(player.checkShow){ if(player.checkShow){
@ -3448,7 +3448,7 @@ window.play={};
} }
else{ else{
if(lib.config.background_ogg){ if(lib.config.background_ogg){
game.playAudio('skill',name); game.playSkillAudio(name);
} }
} }
} }
@ -5053,10 +5053,14 @@ window.play={};
version:0.912, version:0.912,
playAudio:function(){ playAudio:function(){
var str=''; var str='';
var onerror=null;
for(var i=0;i<arguments.length;i++){ for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]==='string'||typeof arguments[i]=='number'){ if(typeof arguments[i]==='string'||typeof arguments[i]=='number'){
str+='/'+arguments[i]; str+='/'+arguments[i];
} }
else if(typeof arguments[i]==='function'){
onerror=arguments[i];
}
} }
var audio=document.createElement('audio'); var audio=document.createElement('audio');
audio.autoplay=true; audio.autoplay=true;
@ -5066,26 +5070,31 @@ window.play={};
this.remove(); this.remove();
}); });
audio.onerror=function(){ audio.onerror=function(){
this.remove(); if(onerror){
onerror.call(this);
}
else{
this.remove();
}
}; };
ui.window.appendChild(audio); ui.window.appendChild(audio);
}, },
playAudioOgg:function(){ playSkillAudio:function(name){
var str=''; var str='audio/skill/';
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]==='string'||typeof arguments[i]=='number'){
str+='/'+arguments[i];
}
}
var audio=document.createElement('audio'); var audio=document.createElement('audio');
audio.autoplay=true; audio.autoplay=true;
audio.volume=lib.config.volumn_audio/8; audio.volume=lib.config.volumn_audio/8;
audio.src='audio-ogg'+str+'.ogg'; audio.src=str+name+'.mp3';
audio.addEventListener('ended',function(){ audio.addEventListener('ended',function(){
this.remove(); this.remove();
}); });
audio.onerror=function(e){ audio.onerror=function(){
this.remove(); if(this._changed){
this.remove();
}
else{
this.src=str+name+Math.ceil(Math.random()*2)+'.mp3';
}
}; };
ui.window.appendChild(audio); ui.window.appendChild(audio);
}, },