In this memory game, when I click the first button and then the second button, everything happens according to the algorithm, but when I click the first button twice, a problem happens ... I wanted to know how to avoid a second click on the first button clicked, type disable it so that it can not receive a second click ... because the button counts every click it receives, so there can not be more than one click.
for (int i=0; i<16; ++i){
if (event.getSource() == buttons[i]){
buttons[i].setGraphic(new ImageView(imgs[Aleatorio[i]]));//novo código
//buttons[i].setVisible(true);
NumeroClick++;
if (NumeroClick == 1) PrimeiroClick = i;
if (NumeroClick == 2){
SegundoClick = i;
///////////////Clicks_não_conseguidos///////////////
if (Aleatorio[PrimeiroClick] != Aleatorio[SegundoClick]){
pontos-=2;
Servico service = new Servico();
service.setOnSucceeded((WorkerStateEvent ev) -> {
buttons[PrimeiroClick].setGraphic(null); //novo código
buttons[PrimeiroClick].setDisable(false);
buttons[SegundoClick].setGraphic(null); //novo código
buttons[SegundoClick].setDisable(false);
});
service.start();
} else {
ContAcertos++;
pontos+=10;
}
NumeroClick = 0;
}
}
}