I have a SplashScreen class( SplashState) which will show first when someone opens my game, and what i want to do is that my Game will show the SplashState for lets say 5 seconds and after 5 seconds, it will switch to my MenuState. How can I do that(btw im a noob in java, sorry if I got you cringed)
My SplashScreen class
import java.awt.Graphics; public class SplashScreen extends State { private int duration; private boolean running = false; public SplashScreen(Handler handler) { super(handler); } @Override public void render(Graphics g) { g.drawImage(Assets.Splash, 0, 0, 1280, 720, null); } @Override public void tick() { if(handler.getMouseManager().isMiddlePressed()) State.setState(handler.getGame().menuState); } public void run() { } public int getDuration() { return duration; } public void setDuration(int duration) { this.duration = duration; } } My State Class(because my splash state extends to this class)
import java.awt.Graphics; import com.vescorspel.game.MyFirstGame.Handler; public abstract class State { private static State currentState = null; public static State setState(State state){ return currentState = state; } public static State getState(){ return currentState; } //CLASS protected Handler handler; public State(Handler handler){ this.handler = handler; } public abstract void tick(); public abstract void render(Graphics g); }