Coverage Summary for Class: SplashScreen (com.mozarellabytes.kroy.Screens)

Class Class, % Method, % Line, %
SplashScreen 0% (0/ 1) 0% (0/ 4) 0% (0/ 13)


1 package com.mozarellabytes.kroy.Screens; 2  3 import com.badlogic.gdx.Gdx; 4 import com.badlogic.gdx.Screen; 5 import com.badlogic.gdx.graphics.Texture; 6 import com.badlogic.gdx.utils.TimeUtils; 7 import com.mozarellabytes.kroy.Kroy; 8 import com.badlogic.gdx.graphics.GL20; 9  10 /** This is the first screen shown when the user starts the game. 11  * It shows the group's logo. 12  */ 13  14 public class SplashScreen implements Screen { 15  16  17  private final Kroy game; 18  19  /** The image displayed as the splash screen */ 20  private final Texture backgroundLogo; 21  22  /** The time that the splash screen has been displayed to the screen */ 23  private long startTime; 24  25  /** Constructor for the splash screen 26  * 27  * @param game LibGDX game 28  */ 29  public SplashScreen(Kroy game) { 30  this.game = game; 31  backgroundLogo = new Texture(Gdx.files.internal("images/backgroundLogo.png"), true); 32  backgroundLogo.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.MipMapLinearNearest); 33  } 34  35  /** Logs the time that the screen was first rendered */ 36  @Override 37  public void show() { 38  startTime = TimeUtils.millis(); 39  } 40  41  /** Renders the splash screen image and changes the screen to the 42  * menu screen after 3 seconds 43  * */ 44  @Override 45  public void render(float delta) { 46  Gdx.gl.glClearColor(0, 0, 0, 1); 47  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 48  49  game.batch.begin(); 50  game.batch.draw(backgroundLogo, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); 51  game.batch.end(); 52  53  if(TimeUtils.timeSinceMillis(startTime) > 3000){ 54  game.setScreen(new ControlsScreen(game, new MenuScreen(game), "menu")); 55  } 56  } 57  58  @Override 59  public void resize(int width, int height) { 60  61  } 62  63  @Override 64  public void pause() { 65  66  } 67  68  @Override 69  public void resume() { 70  71  } 72  73  @Override 74  public void hide() { 75  76  } 77  78  /** Called when this screen should release all resources. */ 79  @Override 80  public void dispose() { 81  backgroundLogo.dispose(); 82  } 83 }