Android : Java Thread.sleep() does not work properly

on Sunday, March 8, 2015


I'm newbie to Java and I have some trouble with delay command. What I want it to do is show my logo for 2 seconds and then go to MainMenu screen. But what it does is it shows black screen for a couple of seconds, and goes to MainMenu(I can see my logo for about 1ms):



public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0.2f, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
game.batch.setProjectionMatrix(camera.combined);

game.batch.begin();
game.batch.draw(PGSImage, 0, 0);
game.batch.end();

try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}

game.setScreen(new MainMenuScreen(game));
dispose();

}


What am I doing wrong? I'm looking for the answer for about an hour now :/


0 comments:

Post a Comment