Compare commits

...

2 Commits

Author SHA1 Message Date
7f359cb01f Merge Hintergrund, Datenbank 2022-01-10 14:22:36 +01:00
4f9de09893 Hintergründe ändern 2022-01-10 14:18:28 +01:00
20 changed files with 101 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -49,10 +49,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();
@ -113,7 +116,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(
@ -177,6 +180,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);
@ -277,6 +287,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
@ -444,6 +501,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);
});
}
/***
@ -517,6 +614,9 @@ public class HappyBirdMain extends Application {
menuButton.setVisible(false);
startGameButton.setVisible(false);
background1.setVisible(false);
background2.setVisible(false);
/*soundSlider ausblenden*/
soundSlider.setVisible(false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB