SHARE
TWEET

SplashScreen.java

a guest Sep 9th, 2014 192 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * This is the very first {@link Screen} which is shown when the game starts. It
  3.  * loads the most common resources and displays a splash image for a couple of
  4.  * seconds. The most common resources are the ones needed for the main menu. The
  5.  * {@link LoadingScreen} will be responsible to load all resources needed for
  6.  * the gaming screen.
  7.  *
  8.  * @author Daniel Holderbaum
  9.  */
  10. public class SplashScreen implements Screen {
  11.  
  12.         private float minimumShowTime = 1.0f;
  13.  
  14.         private OrthographicCamera camera;
  15.  
  16.         private Viewport viewport;
  17.  
  18.         private Texture splash;
  19.  
  20.         @Override
  21.         public void show() {
  22.                 Gdx.input.setCursorCatched(true);
  23.  
  24.                 // assets needed for this screen
  25.                 AssetOrganizer.organizeAssets(AssetOrganizer.getAssetsFromFiles("resources/start.json"));
  26.                 AMazingGame.assets.finishLoading();
  27.  
  28.                 splash = AMazingGame.assets.get("textures/splash.png", Texture.class);
  29.                 camera = new OrthographicCamera();
  30.                 viewport = new FitViewport(splash.getWidth(), splash.getHeight(), camera);
  31.  
  32.                 // initiate loading of common resources
  33.                 AssetOrganizer.organizeAssets(AssetOrganizer.getAssetsFromFiles("resources/menu.json"));
  34.         }
  35.  
  36.         @Override
  37.         public void resume() {
  38.                 AMazingGame.assets.finishLoading();
  39.         }
  40.  
  41.         @Override
  42.         public void render(float deltaTime) {
  43.                 if (AMazingGame.assets.update() && minimumShowTime <= 0) {
  44.                         AMazingGame.messages = AMazingGame.assets.get("messages/messages", I18NBundle.class);
  45.                         I18NBundle.setExceptionOnMissingKey(false);
  46.                         Bullet.init(false, true);
  47.                         AMazingGame.game.setScreen(new MainMenuScreen());
  48.                 }
  49.  
  50.                 Gdx.gl.glClearColor(0.15f, 0.15f, 0.15f, 0f);
  51.                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  52.  
  53.                 AMazingGame.spriteBatch.setProjectionMatrix(camera.combined);
  54.                 AMazingGame.spriteBatch.begin();
  55.                 AMazingGame.spriteBatch.draw(splash, 0, 0);
  56.                 AMazingGame.spriteBatch.end();
  57.  
  58.                 minimumShowTime -= deltaTime;
  59.         }
  60.  
  61.         @Override
  62.         public void resize(int width, int height) {
  63.                 viewport.update(width, height, true);
  64.         }
  65.  
  66.         @Override
  67.         public void pause() {
  68.         }
  69.  
  70.         @Override
  71.         public void hide() {
  72.                 dispose();
  73.         }
  74.  
  75.         @Override
  76.         public void dispose() {
  77.                 Gdx.input.setCursorCatched(false);
  78.         }
  79.  
  80. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top