mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
add: credits layer
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package org.toop.app.layer.layers;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.layer.Container;
|
||||
import org.toop.app.layer.Layer;
|
||||
import org.toop.app.layer.containers.HorizontalContainer;
|
||||
import org.toop.app.layer.containers.VerticalContainer;
|
||||
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public final class CreditsLayer extends Layer {
|
||||
private final int lineHeight = 100;
|
||||
|
||||
private final String[] credits = {
|
||||
"Scrum Master: Stef",
|
||||
"Product Owner: Omar",
|
||||
"Merge Commander: Bas",
|
||||
"Localization: Ticho",
|
||||
"AI: Michiel",
|
||||
"Developers: Michiel, Bas, Stef, Omar, Ticho",
|
||||
"Moral Support: Wesley (voor 1 week)",
|
||||
"OpenGL: Omar"
|
||||
};
|
||||
|
||||
CreditsLayer() {
|
||||
super("credits.css");
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
popAll();
|
||||
|
||||
final Container creditsContainer = new HorizontalContainer(0);
|
||||
|
||||
final Container animatedContainer = new VerticalContainer("animated_credits_container", lineHeight);
|
||||
creditsContainer.addContainer(animatedContainer, true);
|
||||
|
||||
for (final String credit : credits) {
|
||||
animatedContainer.addText("credit-text", credit, false);
|
||||
}
|
||||
|
||||
final Container controlContainer = new VerticalContainer(5);
|
||||
controlContainer.addButton("Back", () -> {
|
||||
App.activate(new MainLayer());
|
||||
});
|
||||
|
||||
addContainer(creditsContainer, Pos.CENTER, 0, 0, 50, 100);
|
||||
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
|
||||
|
||||
playCredits(animatedContainer, App.getHeight());
|
||||
}
|
||||
|
||||
private void playCredits(Container container, double sceneLength) {
|
||||
container.getContainer().setTranslateY(-sceneLength);
|
||||
|
||||
final TranslateTransition scrollCredits = new TranslateTransition(Duration.seconds(20), container.getContainer());
|
||||
scrollCredits.setFromY(-sceneLength - lineHeight);
|
||||
scrollCredits.setToY(sceneLength + lineHeight);
|
||||
|
||||
scrollCredits.setOnFinished(_ -> {
|
||||
final PauseTransition pauseCredits = new PauseTransition(Duration.seconds(3));
|
||||
pauseCredits.setOnFinished(_ -> playCredits(container, sceneLength));
|
||||
pauseCredits.play();
|
||||
});
|
||||
|
||||
scrollCredits.play();
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public final class MainLayer extends Layer {
|
||||
final Container controlContainer = new VerticalContainer(5);
|
||||
|
||||
controlContainer.addButton("Credits", () -> {
|
||||
App.activate(new CreditsLayer());
|
||||
});
|
||||
|
||||
controlContainer.addButton("Options", () -> {
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
-fx-background-color: linear-gradient(to bottom right, #21a7b2, #8f32b9);
|
||||
}
|
||||
|
||||
.vertical_container, .horizontal_container {
|
||||
.stack_container, .vertical_container, .horizontal_container {
|
||||
-fx-padding: 10;
|
||||
|
||||
-fx-alignment: center;
|
||||
-fx-text-alignment: center;
|
||||
|
||||
-fx-background-color: linear-gradient(to bottom right, orange, indigo), #1d1d1d;
|
||||
-fx-background-insets: 0, 2;
|
||||
|
||||
@@ -6,13 +6,7 @@
|
||||
-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.7), 4, 0, 2, 2);
|
||||
}
|
||||
|
||||
.button.exit-button {
|
||||
-fx-background-color: #3498db;
|
||||
-fx-text-fill: white;
|
||||
-fx-font-size: 72px;
|
||||
-fx-padding: 10 20 10 20;
|
||||
-fx-background-radius: 5;
|
||||
}
|
||||
.button.exit-button:hover {
|
||||
-fx-background-color: #2980b9;
|
||||
}
|
||||
.animated_credits_container {
|
||||
-fx-padding: 10;
|
||||
-fx-alignment: center;
|
||||
}
|
||||
Reference in New Issue
Block a user