我正在使用JavaFX做一个简单的视频游戏。我在交流2个课程时遇到问题,因为每个课程都需要其他课程。
这是头等舱:
public final class GUI extends Application {
private Game _game;
private GridPane _taulerVisual;
private Stage _primaryStage;
@Override
public void start(final Stage primaryStage) throws InterruptedException, FileNotFoundException {
//stuff
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
public void addTile(myTile r) {
double x, y;
_taulerVisual.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
double mouseX = e.getSceneX();
double mouseY = e.getSceneY();
addVisualTile(r, mouseX, mouseY);
}
});
}
public void addVisualTile(myTile r, int x, int y) {
myVisualTile rV = new myVisualTile(r);
new myVisualTile add = new myVisualTile();
_taulerVisual.add(rV, x, y);
}
还有更多东西
这是第二堂课:
public class Game {
private GUI _gui;
//more stuff
public void play() {
int x = 100; int y = 100;
myTile ini = _tauler.ini(); // This is the logical board
_gui.addVisualTile(ini, x, y);
Player j;
int i = 0;
while (!_tileStack.empty()) {
try {
if (i == _players.size()) i = 0;
j = _players.get(i);
i++;
turn(j);
wait();
} catch (InterruptedException ex) {
System.out.println("stuff");
}
}
System.out.println("Final");
}
private void turn(Player j) {
myTile r=_tileStack.getFirst();
_gui.addTile(r);
notify();
}
问题在于,我希望每转一圈,直到玩家做出动作(方法转身)。那是有道理的,不是吗?
但是,我该怎么做?
方法play()是从GUI调用的。