summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-06-27 10:27:33 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2018-06-28 16:25:17 +0200
commit7fad3866f825567984dfe60cb75c2ccdb3fcd4cf (patch)
tree952b78a28ada5c5b83cc0f50eca5c045f8ecb779
parent7e8eda722a5e783c773b6a7167d5672a24cfea79 (diff)
downloadgdx-boardgame-7fad3866f825567984dfe60cb75c2ccdb3fcd4cf.zip
gdx-boardgame-7fad3866f825567984dfe60cb75c2ccdb3fcd4cf.tar.gz
LoadingScreen : clean up, count blinks after isLoaded
-rw-r--r--core/src/ch/asynk/zproject/screens/LoadingScreen.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/core/src/ch/asynk/zproject/screens/LoadingScreen.java b/core/src/ch/asynk/zproject/screens/LoadingScreen.java
index 154cc11..598beb9 100644
--- a/core/src/ch/asynk/zproject/screens/LoadingScreen.java
+++ b/core/src/ch/asynk/zproject/screens/LoadingScreen.java
@@ -18,7 +18,7 @@ public class LoadingScreen implements Screen
private final Color c;
private final OrthographicCamera camera;
- private final float DELAY_AFTER = 1f;
+ private final float BLINK_AFTER = 2f;
private final float ALPHA_FACTOR = 1.5f;
private boolean paused;
@@ -29,7 +29,7 @@ public class LoadingScreen implements Screen
private AtlasRegion loaded;
private int x, y;
- private float acc;
+ private int count;
private float percent;
private float alpha;
private boolean incr;
@@ -75,29 +75,33 @@ public class LoadingScreen implements Screen
{
if (paused) return;
- percent = zproject.assets.getProgress();
+ if (!isLoaded) {
+ if (zproject.assets.update()) {
+ ZProject.debug("LoadingScreen", "assets loaded");
+ isLoaded = true;
+ percent = 1f;
+ } else {
+ percent = zproject.assets.getProgress();
+ }
+ }
+
if (!isLoaded && percent >= 1f) {
- acc = 0f;
+ count = 0;
alpha = 1f;
incr = false;
}
- if (isLoaded) {
- acc += delta;
- if (acc >= DELAY_AFTER) {
- // FIXME callback
- // zproject.switchToGame();
- onLoaded.call();
- return;
- }
- }
-
delta *= ALPHA_FACTOR;
if (incr) {
alpha += delta;
if (alpha >= 1f ) {
alpha = 1f;
incr = false;
+ if (isLoaded) count += 1;
+ if (count >= BLINK_AFTER) {
+ onLoaded.call();
+ return;
+ }
}
} else {
alpha -= delta;
@@ -107,13 +111,6 @@ public class LoadingScreen implements Screen
}
}
- if (!isLoaded) {
- if (zproject.assets.update()) {
- ZProject.debug("LoadingScreen", "assets loaded");
- isLoaded = true;
- }
- }
-
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);