Android Open Source - proteus-sidescroller Splash






From Project

Back to project page proteus-sidescroller.

License

The source code is released under:

GNU General Public License

If you think the Android project proteus-sidescroller listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bartholomew.proteus;
//w w  w .j  a v  a  2 s .c  o  m
import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.TweenManager;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.bartholomew.proteus.tween.SpriteAccessor;

public class Splash implements Screen {

  // Necessary variables
  private SpriteBatch m_batch;
  
  // Resources
  private Sprite m_splashSprite;
  private TweenManager m_tweenManager;
  
  
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.1f, 0.5f, 0.8f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    
    m_batch.begin();
    m_splashSprite.draw(m_batch);
    m_batch.end();
    
    // Setup the m_tweenManager
    m_tweenManager.update(delta);
  }

  @Override
  public void resize(int width, int height) {
    m_splashSprite.setSize(width, height);
  }

  @Override
  public void show() {
    m_batch = new SpriteBatch();
    m_tweenManager = new TweenManager();
    Tween.registerAccessor(Sprite.class, new SpriteAccessor());

    Texture splashTexture = new Texture("splash.png");
    m_splashSprite = new Sprite(splashTexture);
    m_splashSprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Set size of the splash screen to window height and width

    Tween.set(m_splashSprite, SpriteAccessor.ALPHA).target(0).start(m_tweenManager);
    // target sprite, which thing are you doing, how many seconds.target(what new value on the thing you are doing it on).start;
    Tween.to(m_splashSprite, SpriteAccessor.ALPHA, 1).target(1).repeatYoyo(1, (float) 1.5).setCallback(new TweenCallback() {
      @Override
      public void onEvent(int type, BaseTween<?> source) {
        ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
      }
    }).start(m_tweenManager);
  
  }

  @Override
  public void hide() {
    dispose();
  }

  @Override
  public void pause() {
    
  }

  @Override
  public void resume() {
    
  }

  @Override
  public void dispose() {
    m_batch.dispose();
    m_splashSprite.getTexture().dispose();
  }

}




Java Source Code List

com.bartholomew.proteus.GameWorld.java
com.bartholomew.proteus.InputController.java
com.bartholomew.proteus.MainActivity.java
com.bartholomew.proteus.MainMenu.java
com.bartholomew.proteus.Main.java
com.bartholomew.proteus.Proteus.java
com.bartholomew.proteus.Splash.java
com.bartholomew.proteus.client.GwtLauncher.java
com.bartholomew.proteus.tween.ActorAccessor.java
com.bartholomew.proteus.tween.SpriteAccessor.java