diff options
| author | ilotterytea <iltsu@alright.party> | 2024-05-29 11:10:56 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-05-29 11:10:56 +0500 |
| commit | fb1302597da5f859959b3edfabfb2aec34e380d9 (patch) | |
| tree | 18da2a48ca053c854b36bb5f8472979a07003fbb | |
| parent | e4c5b7fd1069b5c21fc0643c760adea3a3b9d8f4 (diff) | |
upd: splash screen + cool fade between scenes
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/MenuScreen.java | 6 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/SplashScreen.java | 42 |
2 files changed, 31 insertions, 17 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 273fb14..3c9245e 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -73,6 +73,8 @@ public class MenuScreen implements Screen { // Stage and skin: this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + this.stage.addAction(Actions.sequence(Actions.alpha(0.0f), Actions.alpha(1.0f, 1f))); + this.skin = game.assetManager.get("MainSpritesheet.skin", Skin.class); brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); mainAtlas = game.assetManager.get("MainSpritesheet.atlas", TextureAtlas.class); @@ -209,7 +211,7 @@ public class MenuScreen implements Screen { @Override public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1f); + Gdx.gl.glClearColor(1, 1, 1, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); game.batch.begin(); @@ -218,8 +220,8 @@ public class MenuScreen implements Screen { game.batch.end(); - stage.draw(); stage.act(delta); + stage.draw(); } @Override diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index 0fce7a4..f475dc2 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -3,13 +3,15 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.scenes.scene2d.Action; 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.scenes.scene2d.ui.ProgressBar; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.viewport.FillViewport; +import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.utils.AssetLoading; @@ -20,31 +22,29 @@ public class SplashScreen implements Screen { final Skin skin; TextureAtlas brandAtlas; - Image dev, pub; + Image dev; ProgressBar bar; + private boolean assetsLoaded = false; + public SplashScreen(MaxonGame game) { this.game = game; - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + this.stage = new Stage(new ScreenViewport()); this.skin = new Skin(Gdx.files.internal("MainSpritesheet.skin")); Table logoTable = new Table(); - - logoTable.setSize(stage.getWidth(), stage.getHeight()); - logoTable.setPosition(0, 0); + logoTable.setFillParent(true); logoTable.align(Align.center); brandAtlas = new TextureAtlas(Gdx.files.internal("sprites/gui/ilotterytea.atlas")); - pub = new Image(brandAtlas.findRegion("org")); - logoTable.add(pub).size(pub.getWidth() * 5f, pub.getHeight() * 5f).pad(16f).row(); - dev = new Image(brandAtlas.findRegion("devOld")); - logoTable.add(dev).size(dev.getWidth() * 5f, dev.getHeight() * 5f).row(); + dev.setSize(dev.getWidth() * 5f, dev.getHeight() * 5f); + logoTable.add(dev).size(dev.getWidth(), dev.getHeight()).padBottom(60f).row(); bar = new ProgressBar(0f, 100f, 1f, false, skin); - logoTable.add(bar).size(dev.getWidth() * 5f, 24f); + logoTable.add(bar).width(dev.getWidth()); stage.addActor(logoTable); @@ -57,10 +57,22 @@ public class SplashScreen implements Screen { } private void update() { - if (game.assetManager.update()) { - AssetLoading.registerItems(game.assetManager, game.locale); - game.setScreen(new MenuScreen(game)); - dispose(); + if (game.assetManager.update() && !assetsLoaded) { + stage.addAction( + Actions.sequence( + Actions.alpha(0.0f, 1f), + new Action() { + @Override + public boolean act(float v) { + AssetLoading.registerItems(game.assetManager, game.locale); + game.setScreen(new MenuScreen(game)); + dispose(); + return false; + } + } + ) + ); + assetsLoaded = true; } } |
