var core = {
music: [],//存放音乐的变量
record: false,
apiUrl: "api/",
audio: new Audio(),
api: null,
document.onkeydown = function (event) {
var keyCode = "";
var pressEvent = event || window.event;
if(pressEvent.keyCode){
keyCode = pressEvent.keyCode;
}else if(pressEvent.charCode){
keyCode = pressEvent.charCode;
}else{
keyCode = pressEvent.which;
}
switch (keyCode){
case 65: //a
core.playSound(0);
break;
case 87: //w
core.playSound(8);
break;
case 83: //s
core.playSound(1);
break;
case 69: //e
core.playSound(9);
break;
case 68: //d
core.playSound(2);
break;
case 70: //f
core.playSound(10);
break;
case 84: //t
core.playSound(3);
break;
case 71: //g
core.playSound(11);
break;
case 89: //y
core.playSound(4);
break;
case 72: // h
core.playSound(12);
break;
case 85: // u
core.playSound(5);
break;
case 74: // j
core.playSound(6);
break;
case 75: // k
core.playSound(7);
break;
default :
break;
}
};
}
document.getElementById("record").onclick = function () {
// alert("test");
求指导这里,差一点代码
core.music = [];//把0-11的数字放进去就是录制的东西(0,1,2,3,4,5,6,8,9,10)
core.record = true;
};
1 回答
有的同学
TA贡献31条经验 获得超8个赞
core.music =new Array(); //按下按键的时候 //向数组尾部添加一个元素 core.music.push(0); //播放的时候遍历数组 //值是什么就播放哪个 for(var i = 0, i<= core.music.length; i++) { core.playSound(core.music[i]); }
是这个意思吗
添加回答
举报
0/150
提交
取消