这是一款非常好玩的jquery小游戏,虽然很简单,但确识很好玩和很有挑战性,整理分享给大家,点击屏幕开始奔跑吧兄弟
html5带音乐播放的js奔跑吧兄弟小游戏代码
function MusicObject(url,flag){
this.mobj=new Audio();
this.mobj.src=url;
this.enabled=true;
if(flag){
this.mobj.loop=flag;
this.mobj.addEventListener("ended",function(){
this.currentTime=0;
this.play();
});
}
}
MusicObject.prototype.setEabled=function(flag){
this.enabled=flag;
try{
if(this.mobj.isplayed){
this.mobj.pause();
}
}catch(e){
console.error("音乐停止播放错误!");
}
}
MusicObject.prototype.play=function(){
try{
this.mobj.play();
}catch(e){
console.error("音乐播放错误!");
}
}
MusicObject.prototype.pause=function(){
try{
this.mobj.pause();
}catch(e){
console.error("音乐停止播放错误!");
}
}
MusicObject.prototype.replay=function(){
try{
if(this.mobj.isplayed){
this.mobj.currentTime=0;
}
this.mobj.play();
}catch(e){
console.error("音乐重复播放错误!");
this.mobj.play();
}
}
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791