Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //fields
  2.  
  3. public MainApp() {
  4. this.game = new Game();
  5. }
  6.  
  7. //lots of other methods
  8.  
  9. public void showGameView() {
  10. try {
  11. System.out.println(game.getPlayer().getCurrentRoom());
  12. FXMLLoader loader = new FXMLLoader();
  13. loader.setLocation(MainApp.class.getResource("view/GameView.fxml"));
  14. AnchorPane GameView = (AnchorPane) loader.load();
  15. rootLayout.setCenter(GameView);
  16. GameViewController controller = loader.getController();
  17. controller.setMainApp(this);
  18. } catch (IOException e) {
  19. e.printStackTrace();
  20. }
  21. }
  22.  
  23. public Game getGame() {
  24. return game;
  25. }
  26.  
  27. private MainApp mainApp;
  28.  
  29. @FXML
  30. public void initialize() {
  31. mainApp.getGame(). ... //do something else
  32. }
  33.  
  34. public void setMainApp(MainApp mainApp) {
  35. this.mainApp = mainApp;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement