Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
等待单击以执行Javascript_Javascript_Jquery_Click_Chess - Fatal编程技术网

等待单击以执行Javascript

等待单击以执行Javascript,javascript,jquery,click,chess,Javascript,Jquery,Click,Chess,我正在做一个国际象棋游戏,当我选择一个棋子时,它会向我显示移动棋子的可能方块,我需要代码停在这里,直到用户单击新位置 $('td').click(function(){ //Show posibilities $('td').click(function(){ //i need to stop here until user click again //choose new position and move the piece } } 谢谢你的帮助

我正在做一个国际象棋游戏,当我选择一个棋子时,它会向我显示移动棋子的可能方块,我需要代码停在这里,直到用户单击新位置

$('td').click(function(){
    //Show posibilities

    $('td').click(function(){ //i need to stop here until user click again
        //choose new position and move the piece
    }

}

谢谢你的帮助

您不需要为此停止代码。当用户单击工件时,它会显示可能性,当用户单击其中一个可能的移动时,它会移动。或者,如果再次单击同一块,则会删除可能性。基本上是这样的,

    $('piece').click(function(){
        if(!showed) {
        //Show posibilities
        }else{
        //Remove posibilities
        }

    }
    $('possibilities').click(function(){
        //choose new position and move the piece

    }

我会做内线。cick只适用于可能的移动——就我个人而言,我会使用drag'n'drop,因为它与现实世界的国际象棋非常相似