I have Loading\Logo screen and MainMenu screen in my LibGDX game. And I want to show an interstitial ad between these screens.
I have managed to do this with the following code, but the problem is: after logo screen disappears, main menu screen appears for a short second and only then ad is shown - this is what annoys me.
I want logo screen to hide, then ad to be shown and only then main menu screen to appear (black screens are ok in between). Can you advise me how to get there?
My code now is as follows:
Main class just launches logo screen:
public class Colorem extends Game {
//...
IActivityRequestHandler h_AndroidActivity;
public void create() {
//init vars...
//set logo screen
this.setScreen(new LogoScreen(this));
}
//...
}
Logo screen loads textures using AssetManager and load main menu screen:
public class LogoScreen implements Screen {
private boolean bLoading = false,
bLoadingFinished = false;
public LogoScreen(final Colorem game) {
this.game = game;
// ...
}
@Override
public void render(float delta) {
//draw logo...
//keep loading the resources calling assetManager.update()
if(UI.assetManager.update()) {
game.setScreen(new MainMenuScreen(game));
}
}
}
Main menu class shows Ad when shown:
public class MainMenuScreen implements Screen {
//...
@Override
public void show() {
game.h_AndroidActivity.showInterstitialAd_InGame();
}
}
I have also tried calling Ad from hide() method of LogoScreen, but still I cannot get clean screen ->Ad -> screen slideshow.