From 695ed19c50c81ce9872c38b0ef522515848d9586 Mon Sep 17 00:00:00 2001 From: Recrown Date: Tue, 22 Aug 2017 03:12:50 -0500 Subject: [PATCH] smoothed out transition from loading splash to game menu --- build.gradle | 2 +- .../zero1hd/rhythmbullet/RhythmBullet.java | 17 ++++++++--- .../rhythmbullet/screens/LoadingScreen.java | 30 +++++++++---------- .../rhythmbullet/screens/MainMenu.java | 2 +- .../rhythmbullet/desktop/DesktopLauncher.java | 14 ++++----- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index fa560fe..d0e1c1e 100755 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/core/src/zero1hd/rhythmbullet/RhythmBullet.java b/core/src/zero1hd/rhythmbullet/RhythmBullet.java index 1239c1b..d4c980f 100755 --- a/core/src/zero1hd/rhythmbullet/RhythmBullet.java +++ b/core/src/zero1hd/rhythmbullet/RhythmBullet.java @@ -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)); } diff --git a/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java b/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java index 4b9203e..53b732d 100755 --- a/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java @@ -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(); } @@ -65,15 +62,7 @@ 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() { + } } diff --git a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java index 455e8e4..4abd302 100755 --- a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java +++ b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java @@ -34,7 +34,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { this.core = core; stage = new Stage(new ScreenViewport()); targetPosition = new Vector3(stage.getCamera().position); - + postTransition(); } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java index 545487a..81bcfdc 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java @@ -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); } }