Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package de.cwclan.gdxtest.core.screens; import aurelienribon.tweenengine.BaseTween; import aurelienribon.tweenengine.Tween; 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 de.cwclan.gdxtest.core.tween.SpriteAccessor; import java.awt.Point; /** * * @author simon */ public class Splash implements Screen { private Sprite splash; private SpriteBatch batch; private TweenManager tweenManager; @Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); splash.draw(batch); batch.end(); tweenManager.update(delta); } @Override public void resize(int width, int height) { splash.setSize(width, height); } @Override public void show() { batch = new SpriteBatch(); tweenManager = new TweenManager(); Tween.registerAccessor(Sprite.class, new SpriteAccessor()); Texture texture = new Texture("img/logo.png"); splash = new Sprite(texture); Tween.set(splash, SpriteAccessor.ALPHA).target(0).start(tweenManager); Tween.to(splash, SpriteAccessor.ALPHA, .5f).target(1).repeatYoyo(1, 1) .setCallback((int type, BaseTween<?> source) -> { ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu()); }).start(tweenManager); tweenManager.update(Float.MIN_VALUE); } @Override public void hide() { dispose(); } @Override public void pause() { } @Override public void resume() { } @Override public void dispose() { batch.dispose(); splash.getTexture().dispose(); } }