@FXML AnchorPane gamePane;
public void gameStart() {
if(!Started) {
board = new Board();
stones = new Circle[8][8];
newTurn();
applyBoard();
Started = true;
}
else {
DestroyBoard(); // <--- Erase all the stones
board = new Board();
stones = new Circle[8][8];
newTurn();
applyBoard();
}
}
public void applyBoard() {
for(int i = 0; i < board.boardsize; i++) {
for(int j = 0; j < board.boardsize; j++) {
if(board.board[i][j] != board.EMPTY) {
if(board.board[i][j] == board.BLACK) {
stones[i][j] = new Circle(155 + 90 * j, 85 + 90 * i, 40);
stones[i][j].setFill(Color.BLACK);
gamePane.getChildren().add(stones[i][j]);
}
else if(board.board[i][j] == board.WHITE) {
stones[i][j] = new Circle(155 + 90 * j, 85 + 90 * i, 40);
stones[i][j].setFill(Color.WHITE);
gamePane.getChildren().add(stones[i][j]);
}
}
}
}
}
public void DestroyBoard() { // <---Test Function and not worked!!
gamePane.getChildren().remove(stones[3][3]);
}
我试着让如果再次按下开始按钮,那么船上的所有石头都会被擦除并开始新的游戏。作为第一步,我尝试擦除一个基本的石头,但我无法删除板上的任何石头。我应该怎么做才能解决这个问题?