Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ee.taltech.iti0202.gui;
- import ee.taltech.iti0202.gui.ConfirmWindow.ConfirmWindow;
- import ee.taltech.iti0202.gui.GameLogic.Game;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.input.KeyCode;
- import javafx.scene.input.KeyEvent;
- import javafx.scene.media.AudioClip;
- import javafx.scene.media.Media;
- import javafx.scene.media.MediaPlayer;
- import javafx.stage.Stage;
- import javafx.stage.StageStyle;
- import java.io.IOException;
- import java.net.URL;
- import java.util.ResourceBundle;
- public class ControllerClass {
- private Game game = new Game();
- private Start start = new Start();
- public Stage stage = new Stage();
- @FXML
- private ResourceBundle resources;
- @FXML
- private URL location;
- @FXML
- private ImageView imagegif;
- @FXML
- private Button quitbutton;
- @FXML
- public Button buttonstart;
- @FXML
- private Button buttoninstrction;
- @FXML
- void initialize() {
- quitbutton.setOnAction(e -> closeProgram());
- buttoninstrction.setOnAction(e -> {
- try {
- quitbutton.getScene().getWindow().hide();
- FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("instruction.fxml"));
- Parent root1 = fxmlLoader.load();
- stage.setScene(new Scene(root1, 900, 540));
- stage.showAndWait();
- }catch (Exception i) {
- i.printStackTrace();
- }
- });
- buttonstart.setOnAction(e -> {
- quitbutton.getScene().getWindow().hide();
- start.music.stop();
- try {
- game.background(new Image("file:background.jpg"));
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- });
- }
- private void closeProgram() {
- Boolean answer = ConfirmWindow.display("Are u sure want to exit?");
- if (answer) {
- start.music.stop();
- quitbutton.getScene().getWindow().hide();
- }
- }
- // private void startGame() throws IOException {
- // Parent root = FXMLLoader.load(getClass().getResource("gamebackground.fxml"));
- // Scene scene = new Scene(root, 900, 540);
- // Stage stage = new Stage();
- // stage.initStyle(StageStyle.UNDECORATED);
- // stage.addEventHandler(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
- // if (KeyCode.ESCAPE == event.getCode()) {
- // Boolean answer = ConfirmWindow.display("Are you sure want to exit?");
- // if (answer) {
- // stage.close();
- // }
- // }
- //
- // });
- // stage.setScene(scene);
- // stage.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement