78 lines
2.3 KiB
Java
Raw Normal View History

2017-04-18 18:25:45 -05:00
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.util.TransitionAdapter;
2017-04-18 18:25:45 -05:00
public class LoadingScreen extends ScreenAdapter {
private Stage stage;
Polyjet core;
Image zero1HD;
Screen gotoScreen;
boolean reInit;
public LoadingScreen(Polyjet core, Screen gotoScreen, boolean reInit, boolean timer) {
this.core = core;
this.gotoScreen = gotoScreen;
this.reInit = reInit;
stage = new Stage(new ScreenViewport());
2017-05-16 01:01:57 -05:00
core.getAssetManager().load("splashlogo.png", Texture.class);
core.getAssetManager().finishLoading();
zero1HD = new Image(this.core.getAssetManager().get("splashlogo.png", Texture.class));
2017-04-18 18:25:45 -05:00
zero1HD.setColor(0f,1f,1f,0f);
stage.addActor(zero1HD);
zero1HD.setPosition(stage.getWidth()/2 - zero1HD.getWidth()/2, stage.getHeight()/2 - zero1HD.getHeight()/2);
if (timer) {
zero1HD.addAction(Actions.sequence(Actions.color(Color.WHITE, 1f)));
}
}
float count = 0;
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
2017-05-16 01:01:57 -05:00
if (!zero1HD.hasActions() & core.getAssetManager().update()) {
2017-04-18 18:25:45 -05:00
Gdx.app.debug("Loading Screen", "queue has all been loaded. Action is done playing.");
zero1HD.remove();
core.generateFonts();
core.defineSkinStyles();
if (reInit) {
2017-05-24 23:01:17 -05:00
core.queueAssets();
2017-04-18 18:25:45 -05:00
((TransitionAdapter) gotoScreen).postTransition();
}
core.setScreen(gotoScreen);
2017-05-16 01:01:57 -05:00
core.getAssetManager().unload("splashlogo.png");
core.getAssetManager().get("standard_thrust.p", ParticleEffect.class).flipY();
2017-04-18 18:25:45 -05:00
}
stage.draw();
super.render(delta);
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
super.resize(width, height);
}
}