game_canvas.onclick=function(e)
{var x=e.offsetX;var y =e.offsetY;
var i=Math.ceil(Math.floor(x/15)/2);
var j=Math.ceil(Math.floor(y/15)/2);
if(chess_check[i][j]==0)
{
draw_chess(i,j,s);
if(s)
{chess_check[i][j]=1;s=!s;}
else
{
chess_check[i][j]=2;
s=!s;
}
}
//修改版落子定位坐標(biāo)
{var x=e.offsetX;var y =e.offsetY;
var i=Math.ceil(Math.floor(x/15)/2);
var j=Math.ceil(Math.floor(y/15)/2);
if(chess_check[i][j]==0)
{
draw_chess(i,j,s);
if(s)
{chess_check[i][j]=1;s=!s;}
else
{
chess_check[i][j]=2;
s=!s;
}
}
//修改版落子定位坐標(biāo)
2017-02-02
if(board[i][j] === 0) {
one(i, j, chessColor);
board[i][j] = 1;
chessColor = !chessColor;
}
這樣不是就可以了么,讓點(diǎn)擊過的坐標(biāo)無法執(zhí)行第二次點(diǎn)擊事件,為什么要區(qū)分判斷是黑子還是白子呢?
one(i, j, chessColor);
board[i][j] = 1;
chessColor = !chessColor;
}
這樣不是就可以了么,讓點(diǎn)擊過的坐標(biāo)無法執(zhí)行第二次點(diǎn)擊事件,為什么要區(qū)分判斷是黑子還是白子呢?
2017-01-02
復(fù)習(xí)一下 offsetX offsetY 相對與點(diǎn)擊元素 clientX clientY 相對于瀏覽器窗口可視區(qū)域 screenX screenY相當(dāng)于顯示器
2016-12-24