title: Screen does not appears after few seconds
body: <p>I want the GameOverScreen to appear after few seconds from when the plane collided with one of the rocks, but whenever I run the game , GameOverScreen appears immediately.
  please help me solve this.
  Here's the code.</p>
  
  <pre><code>package com.ravicake.motiontest;
  
  import java.util.Iterator;
  
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.Input.Keys;
  import com.badlogic.gdx.InputProcessor;
  import com.badlogic.gdx.Screen;
  import com.badlogic.gdx.audio.Sound;
  import com.badlogic.gdx.graphics.GL20;
  import com.badlogic.gdx.graphics.OrthographicCamera;
  import com.badlogic.gdx.graphics.Texture;
  import com.badlogic.gdx.graphics.g2d.Animation;
  import com.badlogic.gdx.graphics.g2d.TextureAtlas;
  import com.badlogic.gdx.math.MathUtils;
  import com.badlogic.gdx.math.Rectangle;
  import com.badlogic.gdx.math.Vector3;
  import com.badlogic.gdx.utils.Array;
  import com.badlogic.gdx.utils.TimeUtils;
  
  
  public class GameScreen implements Screen, InputProcessor {
  final MotionTestGame motionTestGame;
  
  Texture rockImage;
  Texture rockImageR;
  Texture playerImage;
  TextureAtlas planeAtlas;
  TextureAtlas sideRockAtlas;
  TextureAtlas explosionAtlas;
  Animation planeAnimation;
  Animation sideRockAnimation;
  Animation explosionAnimation;
  
  Texture bg;
  Sound dropSound;
  Sound bombSound;
  // Music rainMusic;
  OrthographicCamera camera;
  Rectangle player;
  Array&lt;Rectangle&gt; rocksArray;
  Array&lt;Rectangle&gt; rocksArrayR;
  long lastRockTime;
  long lastRockTimeR;
  long explosionTime;
  int speed = 400;
  int lives = 3;
  public float posX, posY;
  float elapsedTime = 0;
  boolean repeatAnimation = true;
  boolean gameover = false;
  
  public void setDropsCollected(int dropsCollected) {
  
  }
  
  public GameScreen(final MotionTestGame game) {
      motionTestGame = game;
      Gdx.input.setInputProcessor(this);
  
  
      rockImage = new Texture(Gdx.files.internal("rockb.png"));
      rockImageR = new Texture(Gdx.files.internal("rocka.png"));
      planeAtlas = new TextureAtlas(Gdx.files.internal("planeAtlas.pack"));
      sideRockAtlas = new TextureAtlas(Gdx.files.internal("siderock.pack"));
      explosionAtlas = new TextureAtlas(Gdx.files.internal("explosionAtlas.pack"));
      planeAnimation = new Animation(1 / 12f, planeAtlas.getRegions());
      sideRockAnimation = new Animation(1 / 9f, sideRockAtlas.getRegions());
      explosionAnimation = new Animation(1 / 9f, explosionAtlas.getRegions());
      // buck = new Texture(Gdx.files.internal("petrol.png"));
      bg = new Texture(Gdx.files.internal("background1.png"));
  
      // load the sound effect and the rain background "music"
      // dropSound = Gdx.audio.newSound(Gdx.files.internal("pick.wav"));
      // bombSound = Gdx.audio.newSound(Gdx.files.internal("bomb.wav"));
      // rainMusic = Gdx.audio.newMusic(Gdx.files.internal("flute.ogg"));
      // rainMusic.setLooping(true);
      // load preference file
  
      // create the camera and the SpriteBatch
      camera = new OrthographicCamera();
      camera.setToOrtho(false, 480, 800);
  
      // create a Rectangle to logically represent the player
      player = new Rectangle();
      player.x = 480 / 2 - 64 / 2; 
      player.y = 650; 
      player.width = 128;
      player.height = 128;
  
      // create the rocks array and spawn the first rock
      rocksArray = new Array&lt;Rectangle&gt;();
      rocksArrayR = new Array&lt;Rectangle&gt;();
      spawnRocks();
      spawnRocksR();
  
  }
  
  private void spawnRocks() {
      // TODO Auto-generated method stub
      Rectangle rock = new Rectangle();
      rock.x = MathUtils.random(-150, -100);
      rock.y = -130;
      rock.width = 256;
      rock.height = 128;
      rocksArray.add(rock);
      lastRockTime = TimeUtils.nanoTime() + 1000000000
              * MathUtils.random(1, 2);
  
  }
  
  private void spawnRocksR() {
      Rectangle rockR = new Rectangle();
      rockR.x = MathUtils.random(300, 400);
      rockR.y = -130;
      rockR.width = 256;
      rockR.height = 128;
      rocksArrayR.add(rockR);
      lastRockTimeR = TimeUtils.nanoTime() + 1000000000
              * MathUtils.random(1, 2);
  
  
      }
  
  
  private void crashed() {
      planeAnimation = explosionAnimation;
      explosionTime = TimeUtils.nanoTime();
      System.out.println("timer started");
  
  }
  
  @Override
  public void render(float delta) {
  
      Gdx.gl.glClearColor(0, 0.5f, 1, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
      // tell the camera to update its matrices.
      camera.update();
  
      // tell the SpriteBatch to render in the
      // coordinate system specified by the camera.
      motionTestGame.batch.setProjectionMatrix(camera.combined);
      elapsedTime += Gdx.graphics.getDeltaTime();
  
      // begin a new batch and draw the player and everything
      //
  
      motionTestGame.batch.begin();
      motionTestGame.batch.draw(bg, 0, 0);
      motionTestGame.font.setScale((float) 1.5);
  
      // game.font.draw(game.batch, "Level: " + level, 710, 470);
      motionTestGame.font.draw(motionTestGame.batch,
              "DROPED: " + (3 - lives), 300, 770);
      motionTestGame.batch.draw(
              planeAnimation.getKeyFrame(elapsedTime, repeatAnimation), player.x,
              player.y);
      motionTestGame.batch.draw(
              sideRockAnimation.getKeyFrame(elapsedTime, repeatAnimation), -165, 0);
      motionTestGame.batch.draw(
              sideRockAnimation.getKeyFrame(elapsedTime, repeatAnimation), 413, 0);
  
      for (Rectangle rock : rocksArray) {
          motionTestGame.batch.draw(rockImage, rock.x, rock.y);
      }
      for (Rectangle rockR : rocksArrayR) {
          motionTestGame.batch.draw(rockImageR, rockR.x, rockR.y);
      }
      motionTestGame.batch.end();
  
      // / accelerometer controls
      player.x -= Gdx.input.getAccelerometerX() * 3;
  
      // process user input
      if (Gdx.input.isTouched()) {
          Vector3 touchPos = new Vector3();
          touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
          camera.unproject(touchPos);
          player.x = touchPos.x - 64 / 2;
  
      }
      if (Gdx.input.isKeyPressed(Keys.LEFT))
          player.x -= 400 * Gdx.graphics.getDeltaTime();
      if (Gdx.input.isKeyPressed(Keys.RIGHT))
          player.x += 400 * Gdx.graphics.getDeltaTime();
  
      // make sure the player stays within the screen bounds
      if (player.x &lt; 0)
          player.x = 0;
      if (player.x &gt; 480 - 64)
          player.x = 480 - 64;
  
      // check if we need to create a new rocks
      if (TimeUtils.nanoTime() - lastRockTime &gt; 1000000000) {
          spawnRocks();
      }
  
      if (TimeUtils.nanoTime() - lastRockTimeR &gt; 1000000000f) {
          spawnRocksR();
  
      }
  
      if (TimeUtils.nanoTime() - explosionTime &gt; 7000000000f) {
  
          gameover=true;
      }
  
  
  
      // ////////// left side rocks
      Iterator&lt;Rectangle&gt; iter = rocksArray.iterator();
      while (iter.hasNext()) {
          Rectangle rock = iter.next();
          rock.y += speed * Gdx.graphics.getDeltaTime();
          if (rock.y + 128 &gt; 1000) {
              iter.remove();
  
          }
  
          if (rock.overlaps(player)) {
  
              crashed();
              //repeatAnimation = false;
          }
      }
  
      // //////// right side rocks
      Iterator&lt;Rectangle&gt; iter2 = rocksArrayR.iterator();
      while (iter2.hasNext()) {
          Rectangle rockR = iter2.next();
          rockR.y += speed * Gdx.graphics.getDeltaTime();
          if (rockR.y + 128 &gt; 1000) {
              iter2.remove();
  
          }
          if (rockR.overlaps(player)) {
  
              crashed();
  
          }
      }
  
      if(gameover){
          motionTestGame.setScreen((new GameOverScreen(motionTestGame)));
          dispose();
      }
  }
  
  
  
  
  
  @Override
  public void resize(int width, int height) {
  }
  
  @Override
  public void show() {
      // start the playback of the background music
      // when the screen is shown
      // rainMusic.play();
  
  }
  
  @Override
  public void hide() {
  }
  
  @Override
  public void pause() {
  }
  
  @Override
  public void resume() {
  }
  
  @Override
  public void dispose() {
      // playerImage.dispose();
      rockImage.dispose();
      rockImageR.dispose();
      // dropSound.dispose();
      // bombSound.dispose();
      sideRockAtlas.dispose();
      planeAtlas.dispose();
      // rainMusic.dispose();
      bg.dispose();
  
  }
  
  
  @Override
  public boolean keyDown(int keycode) {
  
      return false;
  }
  
  @Override
  public boolean keyUp(int keycode) {
      return false;
  }
  
  @Override
  public boolean keyTyped(char character) {
      return false;
  }
  
  @Override
  public boolean touchDown(int screenX, int screenY, int pointer, int button) {
  
      return false;
  }
  
  @Override
  public boolean touchUp(int screenX, int screenY, int pointer, int button) {
  
      return false;
  }
  
  @Override
  public boolean touchDragged(int screenX, int screenY, int pointer) {
      return false;
  }
  
  @Override
  public boolean mouseMoved(int screenX, int screenY) {
      return false;
  }
  
  @Override
  public boolean scrolled(int amount) {
      return false;
  }
  </code></pre>
  
  <p>}</p>