Sunday 23 September 2012

#2.1 Tutorial (LibGDX & MTX) Test5_SplashScreen

TEST SCREEN

Everything is same with previous test screens. I added a loading animation which will fade in 6 seconds and auto go back to all tests screen.





-
























SPLASH / LOADING

If you work with lightweight assets/resorces and making not a very large game you can fake splash and loading screen easily, but if your have large amount of assets and need a real loading performer with percentage you will need AssetManager, pretty cool thing, but I wont be talking about that.


I created a "Loading" object which only extends "AbstractActor", nothing else, I added my loading animation

private void setUpSplash() {
  // #5.1 Test
  // Create a loading anim (NOT REAL), center it
  // "Loading" is a model, it just extends abstractactor
  // #########################################################
  loading = new Loading(getStage().getWidth() / 2 - 50, getStage().getHeight() / 2 - 50, 100, 100);
  loading.setAnimation(Assets.animLoadingSkull, true, true);
  getStage().addActor(loading);
 }




Then in my render method I get the seconds from "AbstractScreen" and 6 seconds later, I make my loading animation fade out, and then auto go to back all tests screen.

 @Override
 public void render(float delta) {
  super.render(delta);
  lblScreenTime.setText(getScreenTime());
  lblFps.setText("Fps: " + Gdx.graphics.getFramesPerSecond());
  
  //
  if(getSecondsTime() > 6){
   loading.addAction(Actions.sequence(
     Actions.fadeOut(0.8f),
     new Action() {
      @Override
      public boolean act(float delta) {
       getGame().setScreen(new Test0_AllTestsScreen(getGame(), "All tests"));
       return false;
      }
     }
   ));
  }
  
 }

DONE IN A FLASH

  • Super fast implementation
  • far less code writing
  • Effective and cool looking
  • Plenty of action types you can use, plus you can create cool animations or particles

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. How can I implement the opening of the game so that loads images from the assets in the second cycle of the splash screen? My class extends the class MainStarter Game and not abstract screen.

    ReplyDelete