作为项目组,我们正在尝试创建一个遍历地图的代理。该地图是使用节点
创建的此代码是定义的运动场。但是我无法显示新形状。有谁知道一种方法,这些形状可以稍后在其他班级中移动?
public double getgridWidth() {
return gridWidth;
}
public double getgridHeight() {
return gridHeight;
}
public static void main(String[] args) {
launch(args);
}
Group root = new Group();
@Override
public void start(Stage primaryStage) {
// initialize playfield
for( int i=0; i < rowCells; i++) {
for (int j = 0; j < columnCells; j++) {
if (i == 0|| i==50) {
Square test = new Square(i * gridWidth, j * gridHeight, gridWidth, gridHeight, false);
root.getChildren().add(test);
Rectangle borderWalls = new Rectangle(i * gridWidth, j * gridHeight, gridWidth, gridHeight);
borderWalls.setHeight(gridHeight);
borderWalls.setWidth(gridWidth);
borderWalls.setStroke(Color.DARKSLATEGREY);
borderWalls.setFill(Color.DARKSLATEGREY);
root.getChildren().addAll(borderWalls);
playfield[i][j] = test;
}
}
for( int i=1; i < 49; i++) {
for( int j=1; j < 49; j++) {
// create node
Square node = new Square( i * gridWidth, j * gridHeight, gridWidth, gridHeight, false);
// add node to group
root.getChildren().add(node);
// add to playfield for further reference using an array
playfield[i][j] = node;
}
}
Run run = new Run();
run.startTimer();
Run noiseTimer = new Run();
noiseTimer.startNoise();
BorderPane pane = new BorderPane();
Menu menu = new Menu(root);
pane.setLeft(root);
pane.setRight(menu.createMenu());
Scene scene = new Scene( pane, windowWidth+menu.menuWidth, windowHeight);
primaryStage.setScene( scene);
primaryStage.show();
primaryStage.setResizable(true);
primaryStage.sizeToScene();
primaryStage.setTitle("Multi Agent Surveillance");