關(guān)于一個棋子點擊兩次會變色的情況,可以
if(chessBoard[i][j]==0){
drawChess(i,j,me);
if(me){
chessBoard[i][j]=1;
}else{
chessBoard[i][j]=2;
}
me != me;
}else{
me=me;
}
if(chessBoard[i][j]==0){
drawChess(i,j,me);
if(me){
chessBoard[i][j]=1;
}else{
chessBoard[i][j]=2;
}
me != me;
}else{
me=me;
}
2016-04-08
我第二行一致報錯
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();
}