Ive tried using a timer in the render method but that just crashes my game, so how do I change screens after a certain amount of time after rendering.

  • \$\begingroup\$ You could have a counter accumulating the elapsed time and when that is greater than or equal to two seconds you change the screen. \$\endgroup\$ – bornander Dec 8 '14 at 9:53
  • \$\begingroup\$ @bornander can you gave an example of how to do that im a bit of a newbie \$\endgroup\$ – dan14941 Dec 8 '14 at 12:45

Track the elapsed time in your Screen, then when a limit is reach as the Game instance to swap to your next screen;

public class MyScreen extends ScreenAdapter {    
  private final Game game;
  private float elapsed;

  public MyScreen(final Game game) {
    this.game = game;

  public void render(float delta) {
    elapsed += delta;

    // Render or do whatever you do here

    if (elapsed > 2.0) {
      game.setScreen(new MyOtherScreen(game));

For this I am assuming you're using http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Game.html and http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Screen.html.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.