Endscreen wahrscheinlich fertig - aber noch keine Einbindung

This commit is contained in:
Mats Pape 2022-01-18 13:56:06 +01:00
parent 775085a1ab
commit 380d469010
9 changed files with 92 additions and 2 deletions

View File

@ -23,6 +23,7 @@ public class HappyBirdMain extends Application {
/*Panes erstellen und zuweisen*/ /*Panes erstellen und zuweisen*/
private final Pane pane = new Pane(); private final Pane pane = new Pane();
private final Pane pause = new Pane(); private final Pane pause = new Pane();
private final Pane endScreen = new Pane();
/*Scene erstellen und zuweisen*/ /*Scene erstellen und zuweisen*/
private final Scene scene = new Scene(pane, 800, 700); private final Scene scene = new Scene(pane, 800, 700);
@ -38,6 +39,9 @@ public class HappyBirdMain extends Application {
private final Label soundLabelPause = new Label("SOUND"); private final Label soundLabelPause = new Label("SOUND");
private final Label highscoreMenuLabel = new Label(); private final Label highscoreMenuLabel = new Label();
private final Label currentScoreEndscreenLabel = new Label("YOUR SCORE: ");
private final Label endScreenHeadline = new Label("GAME OVER");
/*Labels in Arrays speichern*/ /*Labels in Arrays speichern*/
private final Label[] labels = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel, highscoreMenuLabel}; private final Label[] labels = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel, highscoreMenuLabel};
private final Label[] headlineLabels = {headline}; private final Label[] headlineLabels = {headline};
@ -45,7 +49,7 @@ public class HappyBirdMain extends Application {
/*Buttons erstellen und zuweisen*/ /*Buttons erstellen und zuweisen*/
private final Button startButton = new Button("START"); private final Button startButton = new Button("START");
private final Button highscoresButton = new Button("HIGHSCORES"); private final Button highscoresButton = new Button("HIGHSCORES");
private final Button personalHighscoresButton = new Button ("YOUR HIGHSCORES");
private final Button settingsButton = new Button("EINSTELLUNGEN"); private final Button settingsButton = new Button("EINSTELLUNGEN");
private final Button startGameButton = new Button("SPIEL STARTEN"); private final Button startGameButton = new Button("SPIEL STARTEN");
private final Button menuButton = new Button("ZURÜCK"); private final Button menuButton = new Button("ZURÜCK");
@ -57,10 +61,15 @@ public class HappyBirdMain extends Application {
private final Button background1 = new Button(); private final Button background1 = new Button();
private final Button background2 = new Button(); private final Button background2 = new Button();
private final Button backMenuButton = new Button();
private final Button restartGameButton = new Button();
private final Button personalHighscoresButton = new Button ("YOUR SCORES");
/*Buttons in Arrays speichern*/ /*Buttons in Arrays speichern*/
private final Button[] buttons = {startButton, highscoresButton, personalHighscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause, backMenuButton, restartGameButton, personalHighscoresButton};
private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
private final Button[] backgroundButtons = {background1, background2}; private final Button[] backgroundButtons = {background1, background2};
private final Button[] endscreenButtons = {backMenuButton, restartGameButton, personalHighscoresButton};
/*Textfelder erstellen und zuweisen*/ /*Textfelder erstellen und zuweisen*/
private final TextField name = new TextField(); private final TextField name = new TextField();
@ -457,6 +466,9 @@ public class HappyBirdMain extends Application {
"-fx-alignment: center;"); "-fx-alignment: center;");
} }
/*** /***
* Hauptmenü wird ausgeblendet, Nameneingabe folgt * Hauptmenü wird ausgeblendet, Nameneingabe folgt
*/ */
@ -935,11 +947,72 @@ public class HappyBirdMain extends Application {
return true; return true;
} }
/***
* formatiert den End-Screen
*/
public void endScreenFormating() {
/*Endscreen-Pane formatieren*/
endScreen.setPrefSize(400, 500);
pause.setLayoutX(200);
pause.setLayoutY(100);
pause.setStyle("-fx-background-color: #DED894; " +
"-fx-border-width: 5px;" +
"-fx-border-color: #543847;" +
"-fx-border-radius: 15px;" +
"-fx-background-radius: 20px;");
endScreenHeadline.setPrefSize(300,50);
endScreenHeadline.setLayoutX(50);
endScreenHeadline.setLayoutY(10);
endScreenHeadline.setStyle("-fx-background-color: #DED894; " +
"-fx-text-fill: #000000; " +
"-fx-font-size: 35px; " +
"-fx-font-weight: bold;" +
"-fx-alignment: center;");
currentScoreEndscreenLabel.setPrefSize(250,50);
currentScoreEndscreenLabel.setLayoutX(75);
currentScoreEndscreenLabel.setLayoutY(100);
currentScoreEndscreenLabel.setStyle("-fx-background-color: #DED894; " +
"-fx-text-fill: #000000; " +
"-fx-font-size: 35px; " +
"-fx-font-weight: bold;" +
"-fx-alignment: center;");
}
public void generateEndScreen() { public void generateEndScreen() {
endScreenFormating();
/*Name und Highscores ausblenden, Pause-Button ausblenden*/ /*Name und Highscores ausblenden, Pause-Button ausblenden*/
nameLabel.setVisible(false); nameLabel.setVisible(false);
highscoreLabel.setVisible(false); highscoreLabel.setVisible(false);
pauseButton.setVisible(false); pauseButton.setVisible(false);
currentScoreLabel.setVisible(false);
/**/
endScreen.setVisible(true);
endScreen.getChildren().add(currentScoreEndscreenLabel);
currentScoreEndscreenLabel.setVisible(true);
endScreen.getChildren().add(endScreenHeadline);
endScreenHeadline.setVisible(true);
/* Buttons einfügen */
int yPosition = 200;
for (Button button : endscreenButtons) {
button.setLayoutX(100);
button.setLayoutY(yPosition);
yPosition += 100;
endScreen.getChildren().add(button);
button.setVisible(true);
}
pane.getChildren().add(endScreen);
/* Click-Events für die Buttons */
backMenuButton.setOnAction(event -> backMenuButtonClick());
personalHighscoresButton.setOnAction(event -> personalHighscoresButtonClick());
restartGameButton.setOnAction(event -> restartGameButtonClick());
//AB HIER MÜLL
/*Überschrift einblenden - Text auf Game Over setzen */ /*Überschrift einblenden - Text auf Game Over setzen */
headline.setVisible(true); headline.setVisible(true);
@ -951,5 +1024,22 @@ public class HappyBirdMain extends Application {
menuButton.setVisible(true); menuButton.setVisible(true);
/*Button für persönliche Highscores einblenden und positionieren*/ /*Button für persönliche Highscores einblenden und positionieren*/
personalHighscoresButton.setVisible(true); personalHighscoresButton.setVisible(true);
//personalHighscoresButton.setLayoutX();
//personalHighscoresButton.setLayoutY();
}
private void restartGameButtonClick() {
pane.getChildren().remove(endScreen);
startGameButtonClick();
}
private void personalHighscoresButtonClick() {
}
private void backMenuButtonClick() {
pane.getChildren().remove(endScreen);
generateMenueScene();
} }
} }