I am making a grid-style game / simulation based on the โfeelโ and eating errors. I use gridPane (called worldGrid) shortcuts to show grid errors and food. This, obviously, will be constantly updated when an error moves cells towards food, etc.
I currently have a function updateGrid(int col, int row, String cellContent)that I want to replace with a label in [row, col] with a label that has new text in cellContent.
I have the following that works
worldGrid.add(new Label(cellContent), row,col);
However, I'm worried that this is just adding a label on top of the current label and, obviously, over 100 simulation iterations that are not perfect.I tried this before adding a label:
worldGrid.getChildren().remove(row,col);
However, when I try to make a string, addI get IllegalArgumentException.
Any ideas on how to do this? Or even better, any ideas on how best to show an ever-changing grid that will ultimately use sprites instead of text?
source
share