Compare commits

..

No commits in common. "a0d5a48778cc4dedb1eabe7246909785210feda6" and "5e57dfa0222fbe0fd5dad1f36b01bc6b4fc4f91b" have entirely different histories.

11 changed files with 167 additions and 277 deletions

View File

@ -4,76 +4,58 @@ import javafx.application.Application;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.Slider;
import javafx.scene.image.*;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.text.TextAlignment; import javafx.scene.text.TextAlignment;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException;
public class HappyBirdMain extends Application { public class HappyBirdMain extends Application {
/*Panes erstellen und zuweisen*/ private Pane pane = new Pane();
private final Pane pane = new Pane(); private Scene scene = new Scene(pane, 800, 700);
private final Pane pause = new Pane();
/*Scene erstellen und zuweisen*/ private Label nameLabel = new Label("NAME");
private final Scene scene = new Scene(pane, 800, 700); private Label acronymLabel = new Label("KÜRZEL");
private Label headline = new Label("HAPPY BIRD");
private Label soundLabel = new Label("SOUND");
private Label currentScoreLabel = new Label("SCORE");
private Label highscoreLabel = new Label("HIGHSCORE");
private Label pauseMenu = new Label("Pause");
private Label labels[] = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel};
private Label headlineLabels[] = {headline};
/*Labels erstellen und zuweisen*/ private Button startButton = new Button("START");
private final Label nameLabel = new Label("NAME"); private Button highscoresButton = new Button("HIGHSCORES");
private final Label acronymLabel = new Label("KÜRZEL"); private Button settingsButton = new Button("EINSTELLUNGEN");
private final Label headline = new Label("HAPPY BIRD"); private Button startGameButton = new Button("SPIEL STARTEN");
private final Label soundLabel = new Label("SOUND"); private Button menuButton = new Button("ZURÜCK");
private final Label currentScoreLabel = new Label("SCORE"); private Button pauseButton = new Button("PAUSE");
private final Label highscoreLabel = new Label("HIGHSCORE"); private Button continueButton = new Button("WEITERSPIELEN");
private final Label pauseMenuLabel = new Label("PAUSE");
private final Label soundLabelPause = new Label("SOUND");
/*Labels in Arrays speichern*/ private Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton};
private final Label[] labels = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel};
private final Label[] headlineLabels = {headline};
/*Buttons erstellen und zuweisen*/ private TextField name = new TextField();
private final Button startButton = new Button("START"); private TextField acronym = new TextField();
private final Button highscoresButton = new Button("HIGHSCORES");
private final Button settingsButton = new Button("EINSTELLUNGEN");
private final Button startGameButton = new Button("SPIEL STARTEN");
private final Button menuButton = new Button("ZURÜCK");
private final Button pauseButton = new Button("PAUSE");
private final Button continueButton = new Button("WEITERSPIELEN");
private final Button settingsButtonPause = new Button("EINSTELLUNGEN");
private final Button menuButtonPause = new Button("HAUPTMENÜ");
private final Button backButtonPause = new Button("ZURÜCK");
/*Buttons in Arrays speichern*/ private TextField inputFields[] = {name, acronym};
private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
/*Textfelder erstellen und zuweisen*/ private Slider soundSlider = new Slider();
private final TextField name = new TextField();
private final TextField acronym = new TextField();
/*Textfelder in Arrays speichern*/ private Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png", 50, 35, false, false);
private final TextField[] inputFields = {name, acronym};
/*Slider erstellen und zuweisen*/ private Image upperPipe = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeOben.png", 86, 300, false, false);
private final Slider soundSlider = new Slider(); private Image lowerPipe = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeUnten.png", 86, 300, false, false);
private final Slider soundSliderPause = new Slider();
/*Bilder*/ private Pane pause = new Pane();
private final Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png", 50, 35, false, false);
private final Image upperPipe = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeOben.png", 86, 300, false, false); private boolean gameRuns;
private final Image lowerPipe = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeUnten.png", 86, 300, false, false);
/*Variablen für den Spielverlauf*/
//menuScreenRunning: das Hauptmenü ist aufgerufen
private boolean menuScreenRunning;
//gameRunning: das Spiel läuft/ GameScreen ist aufgerufen
private boolean gameRunning;
@ -82,38 +64,48 @@ public class HappyBirdMain extends Application {
} }
@Override @Override
public void start(Stage stage) { public void start(Stage stage) throws IOException {
stage.setTitle("Happy Bird"); stage.setTitle("Happy Bird");
stage.setScene(scene); stage.setScene(scene);
generateMenueScene(); generateMenueScene();
/*ClickEvents:*/ gameRuns = false;
startButton.setOnAction(event -> startButtonClick());
settingsButton.setOnAction(event -> settingsButtonClick()); /**ClickEvents:*/
startButton.setOnAction(event -> {
startButtonClick();
});
highscoresButton.setOnAction(event -> highscoresButtonClick()); settingsButton.setOnAction(event -> {
settingsButtonClick();
});
menuButton.setOnAction(event -> menuButtonClick()); highscoresButton.setOnAction(event -> {
highscoresButtonClick();
});
menuButton.setOnAction(event -> {
menuButtonClick();
});
startGameButton.setOnAction(event -> { startGameButton.setOnAction(event -> {
gameRunning = true; gameRuns = true;
startGameButtonClick(); startGameButtonClick();
}); });
stage.show(); stage.show();
} }
public void generateMenueScene() { public void generateMenueScene() {
menuScreenRunning = true; /**Bild für Hintergrund erstellen:*/
/*Bild für Hintergrund erstellen:*/
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background.png"); Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background.png");
/*Hintergrund erstellen:*/ /**Hintergrund erstellen:*/
BackgroundImage backgroundImage = new BackgroundImage( BackgroundImage backgroundImage = new BackgroundImage(
image, image,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
@ -122,15 +114,29 @@ public class HappyBirdMain extends Application {
BackgroundSize.DEFAULT BackgroundSize.DEFAULT
); );
/*Hintergrund zu Pane hinzufügen:*/ /**Hintergrund zu Pane hinzufügen:*/
Background background = new Background(backgroundImage); Background background = new Background(backgroundImage);
pane.setBackground(background); pane.setBackground(background);
/*Labels formatieren:*/
/**Labels erstellen:*/
//nameLabel = new Label("NAME");
//acronymLabel = new Label("KÜRZEL");
//headline = new Label("HAPPY BIRD");
//soundLabel = new Label("SOUND");
//currentScoreLabel = new Label("SCORE");
//highscoreLabel = new Label("HIGHSCORE");
/**Labels in Arrays speichern:*/
/**Labels formatieren:*/
labelsFormating(labels, pane); labelsFormating(labels, pane);
headlineFormating(headlineLabels, pane); headlineFormating(headlineLabels, pane);
/*alle labels an ihre Stelle:*/ /**alle labels an ihre Stelle:*/
int yPositionLabels = 225; int yPositionLabels = 225;
for (Label label : labels) { for (Label label : labels) {
label.setLayoutX(275); label.setLayoutX(275);
@ -138,44 +144,60 @@ public class HappyBirdMain extends Application {
yPositionLabels += 150; yPositionLabels += 150;
} }
/*headline an ihre Stelle:*/ /**headline an ihre Stelle:*/
headline.setLayoutX(250); headline.setLayoutX(250);
headline.setLayoutY(100); headline.setLayoutY(100);
headline.setVisible(true);
/*soundLabel an seine Stelle:*/ /**soundLabel an seine Stelle:*/
soundLabel.setLayoutY(225); soundLabel.setLayoutY(225);
/*Buttons formatieren:*/
/**Buttons erstellen:*/
//startButton = new Button("START");
//highscoresButton = new Button("HIGHSCORES");
//settingsButton = new Button("EINSTELLUNGEN");
//startGameButton = new Button("SPIEL STARTEN");
//menuButton = new Button("ZURÜCK");
/**Buttons in Array speichern:*/
/**Buttons formatieren:*/
buttonsFormating(buttons, pane); buttonsFormating(buttons, pane);
/*alle Buttons an ihre Stelle:*/ /**alle Buttons an ihre Stelle:*/
int yPositionButtons = 225; int yPositionButtons = 225;
for (Button button : buttons) { for (Button button : buttons) {
button.setLayoutX(300); button.setLayoutX(300);
button.setLayoutY(yPositionButtons); button.setLayoutY(yPositionButtons);
yPositionButtons += 100; yPositionButtons += 100;
button.setVisible(true);
} }
/*menuButton an seine Stelle und vorerst ausblenden:*/ /**menuButton an seine Stelle und vorerst ausblenden:*/
menuButton.setLayoutX(575); menuButton.setLayoutX(575);
menuButton.setLayoutY(625); menuButton.setLayoutY(625);
menuButton.setVisible(false); menuButton.setVisible(false);
/*startGameButton unsichtbar*/ /**startGameButton unsichtbar*/
startGameButton.setVisible(false); startGameButton.setVisible(false);
/*continueButton unsichtbar*/ /**continueButton unsichtbar*/
continueButton.setVisible(false); continueButton.setVisible(false);
/*settingsButtonPause unsichtbar*/
settingsButtonPause.setVisible(false);
/*Textfelder formatieren:*/
/**Textfelder erstellen:*/
//name = new TextField();
//acronym = new TextField();
/**Textfelder in Array speichern:*/
/**Textfelder formatieren:*/
textfieldsFormating(inputFields, pane); textfieldsFormating(inputFields, pane);
/*Textfelder an ihre Position:*/ /**Textfelder an ihre Position:*/
int yPositionInputFields = 290; int yPositionInputFields = 290;
for (TextField feld : inputFields) { for (TextField feld : inputFields) {
feld.setLayoutX(275); feld.setLayoutX(275);
@ -183,8 +205,14 @@ public class HappyBirdMain extends Application {
yPositionInputFields += 150; yPositionInputFields += 150;
} }
/*SoundSlicer anpassen:*/
/**SoundSlider erstellen:*/
//soundSlider = new Slider();
/**SoundSlicer anpassen:*/
soundSliderFormating(soundSlider, pane); soundSliderFormating(soundSlider, pane);
} }
/** /**
@ -192,53 +220,50 @@ public class HappyBirdMain extends Application {
* Sichtbarmachen der richtigen Buttons, Labels, ... * Sichtbarmachen der richtigen Buttons, Labels, ...
*/ */
public void generateGameScreen() { public void generateGameScreen() {
menuScreenRunning = false; /**Headline-Label umbenennen*/
nameLabel.setText("NAME: " + acronym.getText());
/*Headline-Label umbenennen*/ /**Textfelder ausblenden*/
nameLabel.setText("KÜRZEL: " + acronym.getText());
/*Textfelder ausblenden*/
for(TextField feld : inputFields) { for(TextField feld : inputFields) {
feld.setVisible(false); feld.setVisible(false);
} }
/*Labels ausblenden*/ /**Labels ausblenden*/
for (Label label : labels ) { for (Label label : labels )
{
label.setVisible(false); label.setVisible(false);
} }
headline.setVisible(false); headline.setVisible(false);
/*nameLabel positionieren und sichtbar machen*/ /**nameLabel, currentScoreLabel und highscoreLabel positionieren und sichtbar machen*/
nameLabel.setLayoutX(10); nameLabel.setLayoutX(10);
nameLabel.setLayoutY(10); nameLabel.setLayoutY(10);
nameLabel.setVisible(true); nameLabel.setVisible(true);
/*currentScoreLabel positionieren und sichtbar machen*/
currentScoreLabel.setLayoutX(540); currentScoreLabel.setLayoutX(540);
currentScoreLabel.setLayoutY(10); currentScoreLabel.setLayoutY(10);
currentScoreLabel.setVisible(true); currentScoreLabel.setVisible(true);
/*highscoreLabel positionieren und sichtbar machen*/
highscoreLabel.setLayoutX(540); highscoreLabel.setLayoutX(540);
highscoreLabel.setLayoutY(70); highscoreLabel.setLayoutY(70);
highscoreLabel.setVisible(true); highscoreLabel.setVisible(true);
/*Pause-Button positionieren und sichtbar machen*/ /**Übrige Buttons ausblenden*/
startGameButton.setVisible(false);
menuButton.setVisible(false);
/**Pause-Button positionieren und sichtbar machen*/
pauseButton.setLayoutX(575); pauseButton.setLayoutX(575);
pauseButton.setLayoutY(625); pauseButton.setLayoutY(625);
pauseButton.setVisible(true); pauseButton.setVisible(true);
/*übrige Buttons ausblenden*/ /**Vogel hinzufügen, bisher nur als Bild*/
startGameButton.setVisible(false);
menuButton.setVisible(false);
/*Vogel hinzufügen, bisher nur als Bild*/
ImageView birdView = new ImageView(bird); ImageView birdView = new ImageView(bird);
pane.getChildren().add(birdView); pane.getChildren().add(birdView);
birdView.setLayoutY(325); birdView.setLayoutY(325);
birdView.setLayoutX(50); birdView.setLayoutX(50);
/*Pipes oben, unten hinzufügen, bisher nur als Bild*/ /**Pipes oben, unten hinzufügen, bisher nur als Bild*/
ImageView upperPipeView = new ImageView(upperPipe); ImageView upperPipeView = new ImageView(upperPipe);
pane.getChildren().add(upperPipeView); pane.getChildren().add(upperPipeView);
upperPipeView.setLayoutX(400); upperPipeView.setLayoutX(400);
@ -357,71 +382,41 @@ public class HappyBirdMain extends Application {
* Formatiert den PauseScreen * Formatiert den PauseScreen
*/ */
public void pauseScreenFormating() { public void pauseScreenFormating() {
/*pause-Pane formatieren*/
pause.setPrefSize(400, 400);
pause.setLayoutX(200); pause.setLayoutX(200);
pause.setLayoutY(150); pause.setLayoutY(100);
pause.setPrefSize(400, 500);
pause.setStyle("-fx-background-color: #DED894; " + pause.setStyle("-fx-background-color: #DED894; " +
"-fx-border-width: 5px;" + "-fx-border-width: 5px;" +
"-fx-border-color: #543847;" + "-fx-border-color: #543847;" +
"-fx-border-radius: 15px;" + "-fx-border-radius: 15px;" +
"-fx-background-radius: 20px;"); "-fx-background-radius: 20px;");
/*pauseMenuLabel formatieren*/
pauseMenuLabel.setPrefSize(300,50);
pauseMenuLabel.setLayoutX(50);
pauseMenuLabel.setLayoutY(10);
pauseMenuLabel.setStyle("-fx-background-color: #DED894; " +
"-fx-text-fill: #000000; " +
"-fx-font-size: 35px; " +
"-fx-font-weight: bold;" +
"-fx-alignment: center;");
/*soundLabelPause formatieren*/
soundLabelPause.setPrefSize(100, 50);
soundLabelPause.setLayoutX(150);
soundLabelPause.setLayoutY(100);
soundLabelPause.setStyle("-fx-background-color: #DED894; " +
"-fx-text-fill: #000000; " +
"-fx-font-size: 20px; " +
"-fx-font-weight: bold;" +
"-fx-alignment: center;");
} }
/*** /***
* Hauptmenü wird ausgeblendet, Nameneingabe folgt * Hauptmenü wird ausgeblendet, Nameneingabe folgt
*/ */
public void startButtonClick() { public void startButtonClick() {
/*Überschrift umbenennen*/
headline.setText("START"); headline.setText("START");
startGameButton.setOnAction(event -> {
/*alle Buttons ausblenden*/ startGameButtonClick();
});
for(Button button : buttons) { for(Button button : buttons) {
button.setVisible(false); button.setVisible(false);
} }
/*gebrauchte Buttons einblenden, ggf. anpassen*/
menuButton.setVisible(true);
startGameButton.setVisible(true); startGameButton.setVisible(true);
menuButton.setVisible(true);
startGameButton.setLayoutY(520); startGameButton.setLayoutY(520);
/*Textfelder einblenden*/
for(TextField feld : inputFields) { for(TextField feld : inputFields) {
feld.setVisible(true); feld.setVisible(true);
} }
/*Labels einblenden*/
for (Label label : labels ) { for (Label label : labels ) {
label.setVisible(true); label.setVisible(true);
} }
/*nicht verwendete Labels ausblenden*/
highscoreLabel.setVisible(false); highscoreLabel.setVisible(false);
currentScoreLabel.setVisible(false); currentScoreLabel.setVisible(false);
soundLabel.setVisible(false); soundLabel.setVisible(false);
/*Click-Events*/
startGameButton.setOnAction(event -> startGameButtonClick());
} }
@ -429,10 +424,7 @@ public class HappyBirdMain extends Application {
* Hauptmenü wird ausgeblendet, Einstellungen folgen * Hauptmenü wird ausgeblendet, Einstellungen folgen
*/ */
public void settingsButtonClick() { public void settingsButtonClick() {
/*Überschrift umbenennen*/
headline.setText("EINSTELLUNGEN"); headline.setText("EINSTELLUNGEN");
/*nicht verwendete Buttons/ Labels ausblenden, gebrauchte einblenden*/
startButton.setVisible(false); startButton.setVisible(false);
highscoresButton.setVisible(false); highscoresButton.setVisible(false);
settingsButton.setVisible(false); settingsButton.setVisible(false);
@ -441,56 +433,11 @@ public class HappyBirdMain extends Application {
soundLabel.setVisible(true); soundLabel.setVisible(true);
} }
/***
* Hauptmenü wird ausgeblendet, Einstellungen folgen
*/
public void settingsButtonPauseClick() {
/*Überschrift umbenennen*/
pauseMenuLabel.setText("EINSTELLUNGEN");
/*alle Buttons ausblenden*/
for(Button button : pauseButtons) {
button.setVisible(false);
}
/*gebrauchte Buttons einblenden und anpassen*/
backButtonPause.setVisible(true);
backButtonPause.setLayoutY(300);
/*soundSliderPause anpassen und einblenden*/
soundSliderPause.setPrefSize(200, 5);
soundSliderPause.setLayoutX(100);
soundSliderPause.setLayoutY(150);
soundSliderPause.setVisible(true);
/*soundLabelPause einblenden*/
soundLabelPause.setVisible(true);
/*Click-Events*/
backButtonPause.setOnAction(event -> {
/*Überschrift umbenennen*/
pauseMenuLabel.setText("PAUSE");
/*alle Buttons einblenden*/
for(Button button : pauseButtons) {
button.setVisible(true);
}
/*nicht verwendete Buttons ausblenden*/
backButtonPause.setVisible(false);
soundSliderPause.setVisible(false);
soundLabelPause.setVisible(false);
});
}
/*** /***
* Hauptmenü wird ausgeblendet, Highscores folgen * Hauptmenü wird ausgeblendet, Highscores folgen
*/ */
public void highscoresButtonClick() { public void highscoresButtonClick() {
/*Überschrift umbenennen*/
headline.setText("HIGHSCORES"); headline.setText("HIGHSCORES");
/*nicht verwendete Buttons ausblenden, verwendete einblenden*/
startButton.setVisible(false); startButton.setVisible(false);
highscoresButton.setVisible(false); highscoresButton.setVisible(false);
settingsButton.setVisible(false); settingsButton.setVisible(false);
@ -502,28 +449,19 @@ public class HappyBirdMain extends Application {
* Erneutes Anzeigen des Hauptmenüs * Erneutes Anzeigen des Hauptmenüs
*/ */
public void menuButtonClick() { public void menuButtonClick() {
/*Überschrift umbenennen*/
headline.setText("HAPPY BIRD"); headline.setText("HAPPY BIRD");
/*nicht verwendete Buttons ausblenden, verwendete einblenden*/
startButton.setVisible(true); startButton.setVisible(true);
highscoresButton.setVisible(true); highscoresButton.setVisible(true);
settingsButton.setVisible(true); settingsButton.setVisible(true);
menuButton.setVisible(false); menuButton.setVisible(false);
soundSlider.setVisible(false);
soundLabel.setVisible(false);
startGameButton.setVisible(false); startGameButton.setVisible(false);
/*soundSlider ausblenden*/
soundSlider.setVisible(false);
/*soundLabel ausblenden*/
//soundLabel.setVisible(false);
/*Textfelder ausblenden*/
for(TextField feld : inputFields) { for(TextField feld : inputFields) {
feld.setVisible(false); feld.setVisible(false);
} }
/*alle Labels ausblenden*/
for (Label label : labels ) { for (Label label : labels ) {
label.setVisible(false); label.setVisible(false);
} }
@ -535,113 +473,65 @@ public class HappyBirdMain extends Application {
public void startGameButtonClick() { public void startGameButtonClick() {
generateGameScreen(); generateGameScreen();
/*Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
/**Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
pauseButton.setOnAction(event -> { pauseButton.setOnAction(event -> {
if(!menuScreenRunning) { //
pauseButtonClick(gameRunning); if(gameRuns) {
gameRunning = !gameRunning; gameRuns = false;
} else {
gameRuns = true;
} }
pauseButtonClick(gameRuns);
}); });
/*ESC-Tast drücken, um das Pause-Menü aufzurufen*/ /**ESC-Tast drücken, um das Pause-Menü aufzurufen*/
scene.setOnKeyPressed(e -> { scene.setOnKeyPressed(e -> {
if(e.getCode() == KeyCode.ESCAPE && !menuScreenRunning) { if(e.getCode() == KeyCode.ESCAPE) {
pauseButtonClick(gameRunning); if(gameRuns) {
gameRunning = !gameRunning; gameRuns = false;
pauseButtonClick(false);
} else {
gameRuns = true;
pauseButtonClick(true);
}
} }
}); });
} }
/***
* Zurück zum Spiel aus dem PauseScreen heraus
*/
public void continueButtonClick() {
/*pauseButton einblenden*/
pauseButton.setVisible(true);
/*PauseScreen ausblenden*/
pause.setVisible(false);
/*Vom PauseScreen entfernen*/
pause.getChildren().clear();
pane.getChildren().remove(pause);
/*gameRunning auf false setzen, da sonst 2x Click auf Pause-Button bzw. ESC*/
gameRunning = false;
}
/***
* alles vom pane entfernen, da als nächstes zum Hauptmenü
*/
private void menuButtonPauseClick() {
/*alles vom pauseScreen entfernen*/
pause.getChildren().clear();
/*pause von pane entfernen*/
pane.getChildren().clear();
/*gameRunning auf false, da zurück zum Hauptmenü*/
gameRunning = false;
}
/*** /***
* Ruft das Pause-Menü im Spiel auf oder blendet es wieder aus * Ruft das Pause-Menü im Spiel auf oder blendet es wieder aus
*/ */
public void pauseButtonClick(Boolean gameRuns) { public void pauseButtonClick(Boolean gameRuns) {
pauseScreenFormating(); pauseScreenFormating();
/*PauseScreen aufrufen, wenn das Spiel läuft, sonst wieder ausblenden*/ /**PauseScreen aufrufen, wenn das Spiel läuft, sonst wieder ausblenden*/
if(!gameRuns) { if(gameRuns) {
pauseButton.setVisible(false); /**PauseScreen ausblenden*/
/*PauseScreen einblenden*/
pause.setVisible(true); pause.setVisible(true);
pauseButton.setVisible(false);
highscoresButton.setVisible(true);
settingsButton.setVisible(true);
highscoresButton.setLayoutX(100);
settingsButton.setLayoutX(100);
/*Buttons anpassen, zum pauseScreen hinzufügen und einblenden*/ /**Zum PauseScreen hinzufügen*/
int yPosition = 100; pause.getChildren().add(settingsButton);
for(Button button : pauseButtons) { pause.getChildren().add(highscoresButton);
button.setLayoutX(100);
button.setLayoutY(yPosition);
yPosition += 100;
pause.getChildren().add(button);
button.setVisible(true);
}
/*backButtonPause vorerst ausblenden und zu pause hinzufügen*/
backButtonPause.setVisible(false);
pause.getChildren().add(pauseMenuLabel);
/*soundSliderPause vorerst ausblenden und zu pause hinzufügen*/
soundSliderPause.setVisible(false);
pause.getChildren().add(soundSliderPause);
/*soundLabelPause vorerst ausblenden und zu pause hinzufügen*/
soundLabelPause.setVisible(false);
pause.getChildren().add(soundLabelPause);
/*pause zu pane hinzufügen*/
pane.getChildren().add(pause); pane.getChildren().add(pause);
/*ClickEvents*/
continueButton.setOnAction(event -> continueButtonClick());
menuButtonPause.setOnAction(event -> {
menuButtonPauseClick();
generateMenueScene();
});
settingsButtonPause.setOnAction(event -> settingsButtonPauseClick());
} else { } else {
/*pauseButton einblenden*/ /**PauseScreen aufrufen/ sichtbar machen*/
pauseButton.setVisible(true);
/*PauseScreen ausblenden*/
pause.setVisible(false); pause.setVisible(false);
/*alles vom PauseScreen entfernen*/ pauseButton.setVisible(true);
pause.getChildren().clear(); highscoresButton.setVisible(false);
settingsButton.setVisible(false);
highscoresButton.setLayoutX(300);
settingsButton.setLayoutX(300);
/*pause von pane entfernen*/ /**Vom PauseScreen entfernen*/
pause.getChildren().remove(settingsButton);
pause.getChildren().remove(highscoresButton);
pane.getChildren().remove(pause); pane.getChildren().remove(pause);
} }
} }