summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index 6169509..2669e70 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -144,7 +144,7 @@ public class GameScreen implements Screen
float deltaY = ((dragPos.y - y) * cam.zoom * screenToViewport.y);
dragPos.set(x, y);
if (map.drag(deltaX, deltaY)) {
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.getHexAt(cell, touchPos.x, touchPos.y);
} else {
cam.translate(-deltaX, -deltaY, 0);
@@ -157,16 +157,17 @@ public class GameScreen implements Screen
{
if (button == Input.Buttons.LEFT) {
dragPos.set(x, y);
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.touchDown(touchPos.x, touchPos.y);
}
+
return true;
}
@Override
public boolean touchUp(int x, int y, int pointer, int button)
{
if (button == Input.Buttons.LEFT) {
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.touchUp(touchPos.x, touchPos.y);
}
return true;
@@ -184,6 +185,11 @@ public class GameScreen implements Screen
return multiplexer;
}
+ private void unproject(int x, int y, Vector3 v)
+ {
+ cam.unproject(v.set(x, y, 0), mapViewport.getScreenX(), mapViewport.getScreenY(), mapViewport.getScreenWidth(), mapViewport.getScreenHeight());
+ }
+
private void clampCameraPos()
{
float cx = cam.viewportWidth * cam.zoom / 2f;