z-Order im Spielscreen

This commit is contained in:
Lars Alteköster 2022-01-24 12:00:13 +01:00
parent e818be6c17
commit 241bd0f85b
9 changed files with 5 additions and 8 deletions

View File

@ -95,7 +95,7 @@ public class HappyBirdMain extends Application {
private final Slider soundSliderPause = new Slider(); private final Slider soundSliderPause = new Slider();
/*Bilder*/ /*Bilder*/
private final Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png", 50, 35, false, false); private final Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png", 45, 30, false, false);
private final Image pipeTop = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png"); private final Image pipeTop = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png");
private final Image pipeBottom = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png"); private final Image pipeBottom = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png");
@ -109,16 +109,13 @@ public class HappyBirdMain extends Application {
private TranslateTransition top; private TranslateTransition top;
private TranslateTransition bottom; private TranslateTransition bottom;
private TranslateTransition birdTransition;
private Timeline timeline; private Timeline timeline;
private final ArrayList<Transition> transitions = new ArrayList<Transition>();; private final ArrayList<Transition> transitions = new ArrayList<Transition>();;
public static void main(String[] args) { public static void main(String[] args) {
launch(args); launch(args);
} }
@Override @Override
@ -141,7 +138,6 @@ public class HappyBirdMain extends Application {
startGameButtonClick(); startGameButtonClick();
}); });
stage.show(); stage.show();
} }
@ -159,17 +155,18 @@ public class HappyBirdMain extends Application {
Rectangle topPipe = new Rectangle(900, y, 91, 500); Rectangle topPipe = new Rectangle(900, y, 91, 500);
/* Pipe unten; spawnt auf der gleichen Höhe wie obere Pipe /* Pipe unten; spawnt auf der gleichen Höhe wie obere Pipe
* +400, da y-Koord die untere linke Ecke ist * +400 +250, für Abstand zwischen oberer Pipe und unterer Pipe */
* +250, der Abstand zwischen oberer Pipe und unterer Pipe */
Rectangle bottomPipe = new Rectangle(900, y + 400 + 250, 91, 500); Rectangle bottomPipe = new Rectangle(900, y + 400 + 250, 91, 500);
/* oberer Pipe ein Hintergrundbild geben */ /* oberer Pipe ein Hintergrundbild geben */
Image img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png"); Image img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png");
topPipe.setFill(new ImagePattern(pipeTop)); topPipe.setFill(new ImagePattern(pipeTop));
topPipe.setStyle("-fx-view-order: 1");
/* unterer Pipe ein Hintergrundbild geben */ /* unterer Pipe ein Hintergrundbild geben */
img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png"); img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png");
bottomPipe.setFill(new ImagePattern(pipeBottom)); bottomPipe.setFill(new ImagePattern(pipeBottom));
bottomPipe.setStyle("-fx-view-order: 1");
/* neue Animationen über TranslateTransitions */ /* neue Animationen über TranslateTransitions */
top = new TranslateTransition(); top = new TranslateTransition();