diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-06 11:26:46 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-06 11:26:46 +0100 |
commit | 7a3aeabfd8d758944421b71db3e18aacf77bc4de (patch) | |
tree | cb327ebd73a5bb93f645a94526b59acc7ec1fa89 /core/src/ch | |
parent | 9faa5b5c7b49064766bf1fa57509e7ecf1b40981 (diff) | |
download | RustAndDust-7a3aeabfd8d758944421b71db3e18aacf77bc4de.zip RustAndDust-7a3aeabfd8d758944421b71db3e18aacf77bc4de.tar.gz |
GameScreen,Ctrl: mapTouch,hudTouch leave GameScreen for Ctrl
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 17 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/screens/GameScreen.java | 15 |
2 files changed, 17 insertions, 15 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index 63a372a..d4c38e8 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -2,6 +2,8 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.utils.Disposable; +import com.badlogic.gdx.math.Vector3; + import ch.asynk.tankontank.TankOnTank; import ch.asynk.tankontank.ui.Position; import ch.asynk.tankontank.game.State.StateType; @@ -29,6 +31,9 @@ public class Ctrl implements Disposable public boolean blockMap; public boolean blockHud; + public Vector3 mapTouch = new Vector3(); + public Vector3 hudTouch = new Vector3(); + private State selectState; private State pathState; private State rotateState; @@ -245,21 +250,21 @@ public class Ctrl implements Disposable } - public void touchDown(float hx, float hy, float mx, float my) + public void touchDown() { - if (!blockHud && hud.touchDown(hx, hy)) + if (!blockHud && hud.touchDown(hudTouch.x, hudTouch.y)) return; - if (!blockMap && state.downInMap(mx, my)) + if (!blockMap && state.downInMap(mapTouch.x, mapTouch.y)) state.touchDown(); } - public void touchUp(float hx, float hy, float mx, float my) + public void touchUp() { - if (!blockHud && hud.touchUp(hx, hy)) + if (!blockHud && hud.touchUp(hudTouch.x, hudTouch.y)) return; - if (!blockMap && state.upInMap(mx, my)) + if (!blockMap && state.upInMap(mapTouch.x, mapTouch.y)) state.touchUp(); } diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 130c393..ec17cd9 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -14,7 +14,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.math.Vector3; import ch.asynk.tankontank.TankOnTank; @@ -42,8 +41,6 @@ public class GameScreen implements Screen private boolean blocked; private float inputDelay = 0f; private Vector2 dragPos = new Vector2(); - private Vector3 mapTouch = new Vector3(); - private Vector3 hudTouch = new Vector3(); public GameScreen(final TankOnTank game) { @@ -92,9 +89,9 @@ public class GameScreen implements Screen if (blocked) return true; if (button == Input.Buttons.LEFT) { dragPos.set(x, y); - cam.unproject(x, y, mapTouch); - cam.unprojectHud(x, y, hudTouch); - ctrl.touchDown(hudTouch.x, hudTouch.y, mapTouch.x, mapTouch.y); + cam.unproject(x, y, ctrl.mapTouch); + cam.unprojectHud(x, y, ctrl.hudTouch); + ctrl.touchDown(); } return true; } @@ -103,9 +100,9 @@ public class GameScreen implements Screen { if (blocked) return true; if (button == Input.Buttons.LEFT) { - cam.unproject(x, y, mapTouch); - cam.unprojectHud(x, y, hudTouch); - ctrl.touchUp(hudTouch.x, hudTouch.y, mapTouch.x, mapTouch.y); + cam.unproject(x, y, ctrl.mapTouch); + cam.unprojectHud(x, y, ctrl.hudTouch); + ctrl.touchUp(); } return true; } |