SHARE
TWEET
SplashScreen.java
a guest
Sep 9th, 2014
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /**
- * This is the very first {@link Screen} which is shown when the game starts. It
- * loads the most common resources and displays a splash image for a couple of
- * seconds. The most common resources are the ones needed for the main menu. The
- * {@link LoadingScreen} will be responsible to load all resources needed for
- * the gaming screen.
- *
- * @author Daniel Holderbaum
- */
- public class SplashScreen implements Screen {
- private float minimumShowTime = 1.0f;
- private OrthographicCamera camera;
- private Viewport viewport;
- private Texture splash;
- @Override
- public void show() {
- Gdx.input.setCursorCatched(true);
- // assets needed for this screen
- AssetOrganizer.organizeAssets(AssetOrganizer.getAssetsFromFiles("resources/start.json"));
- AMazingGame.assets.finishLoading();
- splash = AMazingGame.assets.get("textures/splash.png", Texture.class);
- camera = new OrthographicCamera();
- viewport = new FitViewport(splash.getWidth(), splash.getHeight(), camera);
- // initiate loading of common resources
- AssetOrganizer.organizeAssets(AssetOrganizer.getAssetsFromFiles("resources/menu.json"));
- }
- @Override
- public void resume() {
- AMazingGame.assets.finishLoading();
- }
- @Override
- public void render(float deltaTime) {
- if (AMazingGame.assets.update() && minimumShowTime <= 0) {
- AMazingGame.messages = AMazingGame.assets.get("messages/messages", I18NBundle.class);
- I18NBundle.setExceptionOnMissingKey(false);
- Bullet.init(false, true);
- AMazingGame.game.setScreen(new MainMenuScreen());
- }
- Gdx.gl.glClearColor(0.15f, 0.15f, 0.15f, 0f);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
- AMazingGame.spriteBatch.setProjectionMatrix(camera.combined);
- AMazingGame.spriteBatch.begin();
- AMazingGame.spriteBatch.draw(splash, 0, 0);
- AMazingGame.spriteBatch.end();
- minimumShowTime -= deltaTime;
- }
- @Override
- public void resize(int width, int height) {
- viewport.update(width, height, true);
- }
- @Override
- public void pause() {
- }
- @Override
- public void hide() {
- dispose();
- }
- @Override
- public void dispose() {
- Gdx.input.setCursorCatched(false);
- }
- }
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.
