Hintergründe ändern
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 5.5 KiB |
@ -47,10 +47,13 @@ public class HappyBirdMain extends Application {
|
||||
private final Button settingsButtonPause = new Button("EINSTELLUNGEN");
|
||||
private final Button menuButtonPause = new Button("HAUPTMENÜ");
|
||||
private final Button backButtonPause = new Button("ZURÜCK");
|
||||
private final Button background1 = new Button();
|
||||
private final Button background2 = new Button();
|
||||
|
||||
/*Buttons in Arrays speichern*/
|
||||
private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
|
||||
private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
|
||||
private final Button[] backgroundButtons = {background1, background2};
|
||||
|
||||
/*Textfelder erstellen und zuweisen*/
|
||||
private final TextField name = new TextField();
|
||||
@ -111,7 +114,7 @@ public class HappyBirdMain extends Application {
|
||||
menuScreenRunning = true;
|
||||
|
||||
/*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/Background0.png");
|
||||
|
||||
/*Hintergrund erstellen:*/
|
||||
BackgroundImage backgroundImage = new BackgroundImage(
|
||||
@ -175,6 +178,13 @@ public class HappyBirdMain extends Application {
|
||||
/*settingsButtonPause unsichtbar*/
|
||||
settingsButtonPause.setVisible(false);
|
||||
|
||||
/*Buttons für Hintergründe*/
|
||||
backgroundButtonsFormating();
|
||||
|
||||
/*Background-Buttons unsichtbar*/
|
||||
background1.setVisible(false);
|
||||
background2.setVisible(false);
|
||||
|
||||
/*Textfelder formatieren:*/
|
||||
textfieldsFormating(inputFields, pane);
|
||||
|
||||
@ -275,6 +285,53 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void backgroundButtonsFormating() {
|
||||
|
||||
int xPosition = 150;
|
||||
|
||||
for(int i=0; i<backgroundButtons.length; i++) {
|
||||
backgroundButtons[i].setPrefSize(200, 175);
|
||||
backgroundButtons[i].setLayoutY(400);
|
||||
backgroundButtons[i].setLayoutX(xPosition);
|
||||
xPosition += 300;
|
||||
|
||||
/*Bild für Hintergrund erstellen:*/
|
||||
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background"+i+"button.png");
|
||||
|
||||
/*Hintergrund erstellen:*/
|
||||
BackgroundImage backgroundImage = new BackgroundImage(
|
||||
image,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.DEFAULT,
|
||||
BackgroundSize.DEFAULT
|
||||
);
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
|
||||
backgroundButtons[i].setBackground(background);
|
||||
|
||||
backgroundButtons[i].setStyle("-fx-border-width: 7px;" +
|
||||
"-fx-border-insets: -7;" +
|
||||
"-fx-border-color: #FFFFFF;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
pane.getChildren().add(backgroundButtons[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
for(Button button : backgroundButtons) {
|
||||
button.setPrefSize(200,150);
|
||||
button.setLayoutY(400);
|
||||
button.setLayoutX(xPosition);
|
||||
xPosition += 300;
|
||||
|
||||
pane.getChildren().add(button);
|
||||
}*/
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle kleinen Labels (keine Überschrift) und fügt sie der Pane hinzu
|
||||
* @param labels LabelArray mit allen Labels
|
||||
@ -442,6 +499,46 @@ public class HappyBirdMain extends Application {
|
||||
menuButton.setVisible(true);
|
||||
soundSlider.setVisible(true);
|
||||
soundLabel.setVisible(true);
|
||||
|
||||
background1.setVisible(true);
|
||||
background2.setVisible(true);
|
||||
|
||||
|
||||
background1.setOnAction(event -> {
|
||||
/*Bild für Hintergrund erstellen:*/
|
||||
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background0.png");
|
||||
|
||||
/*Hintergrund erstellen:*/
|
||||
BackgroundImage backgroundImage = new BackgroundImage(
|
||||
image,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.DEFAULT,
|
||||
BackgroundSize.DEFAULT
|
||||
);
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
pane.setBackground(background);
|
||||
});
|
||||
|
||||
background2.setOnAction(event -> {
|
||||
/*Bild für Hintergrund erstellen:*/
|
||||
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background1.png");
|
||||
|
||||
/*Hintergrund erstellen:*/
|
||||
BackgroundImage backgroundImage = new BackgroundImage(
|
||||
image,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.DEFAULT,
|
||||
BackgroundSize.DEFAULT
|
||||
);
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
pane.setBackground(background);
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
@ -515,6 +612,9 @@ public class HappyBirdMain extends Application {
|
||||
menuButton.setVisible(false);
|
||||
startGameButton.setVisible(false);
|
||||
|
||||
background1.setVisible(false);
|
||||
background2.setVisible(false);
|
||||
|
||||
/*soundSlider ausblenden*/
|
||||
soundSlider.setVisible(false);
|
||||
|
||||
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 5.5 KiB |