我第二行一致報(bào)錯(cuò)
var chess=document.getElementById('chess');
var context=chess.getContext('2d');
context.strokeStyle='#BFBFBF';
for(var i=0;i<15;i++){
context.moveTo(15+1*30,15);
context.lineTo(15+1*30,15);
context.stroke();
context.moveTo(15,15+1*30);
context.lineTo(15,15+1*30);
context.stroke();
}
var chess=document.getElementById('chess');
var context=chess.getContext('2d');
context.strokeStyle='#BFBFBF';
for(var i=0;i<15;i++){
context.moveTo(15+1*30,15);
context.lineTo(15+1*30,15);
context.stroke();
context.moveTo(15,15+1*30);
context.lineTo(15,15+1*30);
context.stroke();
}
chess.onclick = function(e) {
。。。
var j = Math.floor(y / 30);
if(chessBoard[i][j] == 0) {
oneStep(i, j, me);
if(me) {
chessBoard[i][j] = 1;
}else{
chessBoard[i][j] = 2;
}
me = !me;
}
}
這段代碼,若J相同,數(shù)組的值不能重置為0呢?就進(jìn)不去了呢?
。。。
var j = Math.floor(y / 30);
if(chessBoard[i][j] == 0) {
oneStep(i, j, me);
if(me) {
chessBoard[i][j] = 1;
}else{
chessBoard[i][j] = 2;
}
me = !me;
}
}
這段代碼,若J相同,數(shù)組的值不能重置為0呢?就進(jìn)不去了呢?
2016-03-31