summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/zproject/ZProject.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-06-27 00:18:54 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2018-06-28 16:24:42 +0200
commitb6f07387af85687bf957e3e75e664be5ce972bd4 (patch)
treed80d10fd85e911d1a633e5b59735ec6a8532223f /core/src/ch/asynk/zproject/ZProject.java
parentfb5a31554b5dc909d5de25eae306d6033d25c907 (diff)
downloadgdx-boardgame-b6f07387af85687bf957e3e75e664be5ce972bd4.zip
gdx-boardgame-b6f07387af85687bf957e3e75e664be5ce972bd4.tar.gz
implement LoadingScreen
Diffstat (limited to 'core/src/ch/asynk/zproject/ZProject.java')
-rw-r--r--core/src/ch/asynk/zproject/ZProject.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/src/ch/asynk/zproject/ZProject.java b/core/src/ch/asynk/zproject/ZProject.java
index 12dc982..7afca28 100644
--- a/core/src/ch/asynk/zproject/ZProject.java
+++ b/core/src/ch/asynk/zproject/ZProject.java
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import ch.asynk.zproject.screens.GameScreen;
+import ch.asynk.zproject.screens.LoadingScreen;
public class ZProject extends Game
{
@@ -13,7 +14,8 @@ public class ZProject extends Game
private enum State
{
NONE,
- GAME
+ LOADING,
+ GAME,
}
private State state;
@@ -24,7 +26,7 @@ public class ZProject extends Game
this.state = State.NONE;
Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG);
debug(String.format("create() [%d;%d] %f", Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Gdx.graphics.getDensity()));
- switchToGame();
+ switchToLoading();
}
@Override public void dispose()
@@ -55,6 +57,7 @@ public class ZProject extends Game
return;
}
switch(state) {
+ case LOADING: assets.unloadLoading(); break;
case GAME: assets.unloadGame(); break;
}
if (state != State.NONE) {
@@ -69,10 +72,15 @@ public class ZProject extends Game
switchTo(null, State.NONE);
}
- public void switchToGame()
+ public void switchToLoading()
{
- assets.loadGame();
+ assets.loadLoading();
assets.finishLoading();
+ switchTo(new LoadingScreen(this, () -> assets.loadGame(), () -> switchToGame()), State.LOADING);
+ }
+
+ public void switchToGame()
+ {
switchTo(new GameScreen(this), State.GAME);
}
}