Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. package ee.taltech.iti0202.gui;
  2.  
  3. import ee.taltech.iti0202.gui.ConfirmWindow.ConfirmWindow;
  4. import ee.taltech.iti0202.gui.GameLogic.Game;
  5. import javafx.fxml.FXML;
  6. import javafx.fxml.FXMLLoader;
  7. import javafx.scene.Parent;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.Button;
  10. import javafx.scene.image.Image;
  11. import javafx.scene.image.ImageView;
  12. import javafx.scene.input.KeyCode;
  13. import javafx.scene.input.KeyEvent;
  14. import javafx.scene.media.AudioClip;
  15. import javafx.scene.media.Media;
  16. import javafx.scene.media.MediaPlayer;
  17. import javafx.stage.Stage;
  18. import javafx.stage.StageStyle;
  19.  
  20. import java.io.IOException;
  21. import java.net.URL;
  22. import java.util.ResourceBundle;
  23.  
  24. public class ControllerClass {
  25. private Game game = new Game();
  26. private Start start = new Start();
  27. public Stage stage = new Stage();
  28.  
  29.  
  30.  
  31.  
  32. @FXML
  33. private ResourceBundle resources;
  34.  
  35. @FXML
  36. private URL location;
  37.  
  38. @FXML
  39. private ImageView imagegif;
  40.  
  41. @FXML
  42. private Button quitbutton;
  43.  
  44. @FXML
  45. public Button buttonstart;
  46.  
  47. @FXML
  48. private Button buttoninstrction;
  49.  
  50. @FXML
  51. void initialize() {
  52. quitbutton.setOnAction(e -> closeProgram());
  53.  
  54. buttoninstrction.setOnAction(e -> {
  55. try {
  56. quitbutton.getScene().getWindow().hide();
  57. FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("instruction.fxml"));
  58. Parent root1 = fxmlLoader.load();
  59. stage.setScene(new Scene(root1, 900, 540));
  60. stage.showAndWait();
  61. }catch (Exception i) {
  62. i.printStackTrace();
  63. }
  64.  
  65.  
  66. });
  67.  
  68. buttonstart.setOnAction(e -> {
  69. quitbutton.getScene().getWindow().hide();
  70. start.music.stop();
  71. try {
  72. game.background(new Image("file:background.jpg"));
  73. } catch (Exception e1) {
  74. e1.printStackTrace();
  75. }
  76. });
  77.  
  78.  
  79. }
  80.  
  81. private void closeProgram() {
  82. Boolean answer = ConfirmWindow.display("Are u sure want to exit?");
  83. if (answer) {
  84. start.music.stop();
  85. quitbutton.getScene().getWindow().hide();
  86. }
  87. }
  88.  
  89. // private void startGame() throws IOException {
  90. // Parent root = FXMLLoader.load(getClass().getResource("gamebackground.fxml"));
  91. // Scene scene = new Scene(root, 900, 540);
  92. // Stage stage = new Stage();
  93. // stage.initStyle(StageStyle.UNDECORATED);
  94. // stage.addEventHandler(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
  95. // if (KeyCode.ESCAPE == event.getCode()) {
  96. // Boolean answer = ConfirmWindow.display("Are you sure want to exit?");
  97. // if (answer) {
  98. // stage.close();
  99. // }
  100. // }
  101. //
  102. // });
  103. // stage.setScene(scene);
  104. // stage.show();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement