Added Loading animation and transitioning to StartScene

This commit is contained in:
2026-06-22 08:42:22 +02:00
parent db84385269
commit f6f97d92bd
+12 -12
View File
@@ -1,28 +1,25 @@
package project.scenes; package project.scenes;
import pi.Camera; import pi.Controller;
import pi.Scene; import pi.Scene;
import pi.Text; import pi.Text;
import pi.actor.Image; import pi.actor.Image;
import pi.event.FrameListener;
import static pi.Controller.fonts; import static pi.Controller.fonts;
import java.awt.Font; import java.awt.Font;
public class LoadingScene extends Scene implements FrameListener public class LoadingScene extends Scene
{ {
private Text title; private Text title;
private Text subtitle; private Text subtitle;
private String subtitle_content; private String subtitle_content;
private Image tatli; private Image tatli;
private double lastUpdated;
public LoadingScene() { public LoadingScene() {
title = new Text("Royal Kebab"); title = new Text("Royal Kebab");
subtitle_content = "Loading"; subtitle_content = "Loading";
subtitle = new Text(subtitle_content); subtitle = new Text(subtitle_content);
tatli = new Image("images/kebab-pack/tatli-ekmek-256x256.png"); tatli = new Image("images/kebab-pack/tatli-ekmek-256x256.png");
lastUpdated = System.currentTimeMillis();
Font font = fonts.get("Fonts/BitcountGridDouble-Regular.ttf"); Font font = fonts.get("Fonts/BitcountGridDouble-Regular.ttf");
title.center(0, 3); title.center(0, 3);
@@ -36,13 +33,16 @@ public class LoadingScene extends Scene implements FrameListener
add(title); add(title);
add(subtitle); add(subtitle);
add(tatli); add(tatli);
}
public void onFrame(double pastTime) repeat(0.5, 4, (int i)->{
{ remove(subtitle);
if(System.currentTimeMillis() - lastUpdated > 300) {
subtitle_content = subtitle_content + "."; subtitle_content = subtitle_content + ".";
subtitle.content(subtitle_content); subtitle = new Text(subtitle_content);
} subtitle.center(0, -3);
} subtitle.font(font);
add(subtitle);
}, (int i)->{
Controller.transitionToScene(new StartScene());
});
}
} }