diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-14 23:30:55 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-14 23:30:55 +0200 |
commit | 89eff7909cc161df57a5ac0e0a126a2a2cd08237 (patch) | |
tree | b7f4fb3efbb40ae6037870c789d221b13d616f16 /core | |
parent | 61035b776b881050625ac5b1789f03aeb4ae4e5d (diff) | |
download | RustAndDust-89eff7909cc161df57a5ac0e0a126a2a2cd08237.zip RustAndDust-89eff7909cc161df57a5ac0e0a126a2a2cd08237.tar.gz |
smoothen zoom factor
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/screens/GameScreen.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 571123e..e550357 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -29,9 +29,9 @@ import ch.asynk.tankontank.actors.HexMap; public class GameScreen extends AbstractScreen { - static private final float ZOOM_MAX = 0.1f; - static private final float ZOOM_GESTURE_FACTOR = 300.f; - static private final float ZOOM_SCROLL_FACTOR = 10.0f; + static private final float ZOOM_MAX = 0.2f; + static private final float ZOOM_GESTURE_FACTOR = .01f; + static private final float ZOOM_SCROLL_FACTOR = .1f; private float maxZoomOut; final OrthographicCamera cam; @@ -87,7 +87,10 @@ public class GameScreen extends AbstractScreen @Override public boolean zoom(float initialDistance, float distance) { - cam.zoom += ((initialDistance - distance) / ZOOM_GESTURE_FACTOR); + if (initialDistance > distance) + cam.zoom += ZOOM_GESTURE_FACTOR; + else + cam.zoom -= ZOOM_GESTURE_FACTOR; cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_MAX, maxZoomOut); clampCameraPos(); return true; @@ -135,7 +138,7 @@ public class GameScreen extends AbstractScreen @Override public boolean scrolled(int amount) { - cam.zoom += amount / ZOOM_SCROLL_FACTOR; + cam.zoom += amount * ZOOM_SCROLL_FACTOR; cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_MAX, maxZoomOut); clampCameraPos(); return true; |