大家好,我正在制作一个记忆游戏,它是一个 4x4 棋盘,您单击图块以显示下面的内容,您必须找到相应的图片。我在鼠标单击并将它们分配给guess1 和guess2 背后的逻辑时遇到问题。
Joption 面板是我测试猜测 1 和猜测 2 是否注册的方式。每次guess1都能正常工作,但我不知道如何让第二个猜测起作用这是我的尝试。
public void displayHit(Graphics g)
{
//earlier on in the code mouseClicked provides the x and y indexes for the place where you click
if (mouseClicked)
{
//method I coded to assign whereever you clicked on the 400x400 board to match the 4x4 array
centerClick(x1,y1);
guess1 = board[row][column];
board[row][column] = board[x1][y1];
guess1 = board[x1][y1];
JOptionPane.showInputDialog(guess1 + "this is guess1");
guess2 = -1;
setColor(g);
centerHit(xMouse, yMouse);
g.fillOval(xMouse, yMouse, 40, 40);
mouseClicked = false;
if ((guess2 == -1) && (mouseClicked))
{
centerClick(x1,y1);
guess2 = board[row][column];
board[row][column] = board[x1][y1];
guess2 = board[x1][y1];
JOptionPane.showInputDialog(guess2 + "this is guess2");
}
}