smoothed out transition from loading splash to game menu

This commit is contained in:
Harrison Deng 2017-08-22 03:12:50 -05:00
parent e8a96bbc87
commit 695ed19c50
5 changed files with 35 additions and 30 deletions

View File

@ -38,7 +38,7 @@ project(":desktop") {
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}

View File

@ -36,6 +36,7 @@ import zero1hd.rhythmbullet.util.GenericFileTypeHandler;
import zero1hd.rhythmbullet.util.RoundingResolutionHandler;
import zero1hd.rhythmbullet.util.TransitionAdapter;
public class RhythmBullet extends Game {
private boolean initComplete = false;
private boolean resizing;
@ -58,6 +59,12 @@ public class RhythmBullet extends Game {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
prefs = Gdx.app.getPreferences("PolyJet_Preferences");
if (getPrefs().getBoolean("fullscreen", true)) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else {
Gdx.graphics.setWindowedMode(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
}
Resolution[] resolution = {
new Resolution(800, 480, "800x480"),
new Resolution(1280, 720, "1280x720"),
@ -69,19 +76,21 @@ public class RhythmBullet extends Game {
new Resolution(3840, 2160, "3840x2160"),
};
InternalFileHandleResolver internalFileResolver = new InternalFileHandleResolver();
rRHandler = new RoundingResolutionHandler(internalFileResolver, resolution);
GenericFileTypeHandler genericFileFinder = new GenericFileTypeHandler(internalFileResolver);
assetManager.setLoader(TextureAtlas.class, new TextureAtlasLoader(rRHandler));
assetManager.setLoader(Texture.class, new TextureLoader(rRHandler));
assetManager.setLoader(ParticleEffect.class, new ParticleEffectLoader(genericFileFinder));
assetManager.setLoader(Sound.class, new SoundLoader(genericFileFinder));
resizing = false;
default_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Gasalt-Regular.ttf"));
darktech_ldr_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/darktech_ldr.ttf"));
getrRHandler().setResolution(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
Gdx.app.debug("Prelaunch Debug Info", "\ncurrent window size: "
+ Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() +"\n"
+ "Pixel density (PPI): " + Gdx.graphics.getDensity());
setScreen(new LoadingScreen(this));
}

View File

@ -1,5 +1,6 @@
package zero1hd.rhythmbullet.screens;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
@ -13,29 +14,25 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
public class LoadingScreen extends ScreenAdapter {
public class LoadingScreen extends ScreenAdapter implements ApplicationListener {
private Stage stage;
RhythmBullet core;
Image zero1HD;
private boolean done;
public LoadingScreen(RhythmBullet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
core.getAssetManager().load("splashlogo.png", Texture.class);
core.getAssetManager().finishLoading();
stage = new Stage(new ScreenViewport());
zero1HD = new Image(this.core.getAssetManager().get("splashlogo.png", Texture.class));
zero1HD.setColor(0f,1f,1f,0f);
stage.addActor(zero1HD);
zero1HD.setPosition(stage.getWidth()/2 - zero1HD.getWidth()/2, stage.getHeight()/2 - zero1HD.getHeight()/2);
zero1HD.addAction(Actions.sequence(Actions.color(Color.WHITE, 1f), Actions.fadeOut(0.5f)));
core.getrRHandler().setResolution(core.getPrefs().getInteger("screen-width"), core.getPrefs().getInteger("screen-height"));
core.queueAssets();
}
@ -66,14 +63,6 @@ public class LoadingScreen extends ScreenAdapter {
core.generateFonts(core.getPrefs().getInteger("screen-height"));
core.defineSkinStyles();
if (core.getPrefs().getBoolean("fullscreen", true)) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else {
Gdx.graphics.setWindowedMode(core.getPrefs().getInteger("screen-width"), core.getPrefs().getInteger("screen-height"));
}
Gdx.app.debug("Prelaunch Debug Info", "\ncurrent window size: "
+ Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() +"\n"
+ "Pixel density (PPI): " + Gdx.graphics.getDensity());
core.setScreen(new MainMenu(core));
zero1HD.remove();
core.getAssetManager().unload("splashlogo.png");
@ -92,4 +81,13 @@ public class LoadingScreen extends ScreenAdapter {
core.setInitComplete();
super.hide();
}
@Override
public void create() {
}
@Override
public void render() {
}
}

View File

@ -1,17 +1,15 @@
package zero1hd.rhythmbullet.desktop;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import zero1hd.rhythmbullet.RhythmBullet;
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setTitle("Rhythm Bullet");
config.setResizable(false);
config.setWindowSizeLimits(800, 480, 3840, 2160);
config.setWindowedMode(400, 400);
new Lwjgl3Application(new RhythmBullet(), config);
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "Rhythm Bullet";
config.resizable = false;
new LwjglApplication(new RhythmBullet(), config);
}
}