diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-06 20:11:28 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-06 20:11:28 +0100 |
commit | abd0ea69183a36c6a3e818edcdc1883a97be8b3a (patch) | |
tree | 48699ea987c43a8d55beb0276f487a3ca254144b /core | |
parent | 6972a5e1aa691cb87eacf24eb7f14734b7834c7b (diff) | |
download | RustAndDust-abd0ea69183a36c6a3e818edcdc1883a97be8b3a.zip RustAndDust-abd0ea69183a36c6a3e818edcdc1883a97be8b3a.tar.gz |
GameScreen: do not render or resize when on pause
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/RustAndDust.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/screens/GameScreen.java | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java index 1d8cd70..9334123 100644 --- a/core/src/ch/asynk/rustanddust/RustAndDust.java +++ b/core/src/ch/asynk/rustanddust/RustAndDust.java @@ -255,11 +255,13 @@ public class RustAndDust extends Game public void pause() { debug("RustAndDust", "pause()"); + getScreen().pause(); } @Override public void resume() { debug("RustAndDust", "resume()"); + getScreen().resume(); } } diff --git a/core/src/ch/asynk/rustanddust/screens/GameScreen.java b/core/src/ch/asynk/rustanddust/screens/GameScreen.java index 6c58c1b..a1e759f 100644 --- a/core/src/ch/asynk/rustanddust/screens/GameScreen.java +++ b/core/src/ch/asynk/rustanddust/screens/GameScreen.java @@ -41,6 +41,7 @@ public class GameScreen implements Screen private final RustAndDust game; private Ctrl ctrl; + private boolean paused; private int dragged; private boolean blocked; private float inputDelay = 0f; @@ -63,6 +64,8 @@ public class GameScreen implements Screen if (DEBUG) this.debugShapes = new ShapeRenderer(); Gdx.input.setInputProcessor(getMultiplexer()); + + paused = false; } private InputMultiplexer getMultiplexer() @@ -138,6 +141,8 @@ public class GameScreen implements Screen @Override public void render(float delta) { + if (paused) return; + if (inputDelay > 0f) { inputDelay -= delta; if (inputDelay <= 0f) @@ -186,6 +191,8 @@ public class GameScreen implements Screen @Override public void resize(int width, int height) { + if (paused) return; + // RustAndDust.debug("GameScreen", "resize (" + width + "," + height + ")"); cam.updateViewport(width, height); ctrl.hud.resize(cam.getHudLeft(), cam.getHudBottom(), cam.getHudWidth(), cam.getHudHeight()); @@ -215,12 +222,14 @@ public class GameScreen implements Screen @Override public void pause() { - // RustAndDust.debug("GameScreen", "pause()"); + paused = true; + RustAndDust.debug("RustAndDust", "pause() "); } @Override public void resume() { - // RustAndDust.debug("GameScreen", "resume()"); + RustAndDust.debug("RustAndDust", "resume() "); + paused = false; } } |