我正在制作一个 jquery 扫雷器,目前正在研究当您单击具有0
相邻地雷的块时的显示功能。预期的结果是遍历所有 8 个相邻块以显示这些块,如果它们也是 ' 0
' 块,它会针对该块重复:
function reveal(block) {
block.removeClass('hide');
var thex = getXY(block)[0];
var they = getXY(block)[1];
if (blockNumber(block) == '0') {
alert('test');
--they;
--thex;
var nearmines = 0;
for (mody=0;mody<3;mody++){
for (modx=0;modx<3;modx++){
var newx = thex + modx;
var newy = they + mody;
reveal(bl(newx,newy));
}
}
}
}
目前,该函数在每次函数迭代时检查第一个块后停止。似乎呼叫正在中断for loops
.