summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:48:12 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-17 16:48:12 +0100
commit2c4d6504abbd51a177aa173dde6ebd37fe765754 (patch)
tree2559140740665bed888151c95b898ea012402948
parent0bfea1c03f0ab6fef63e29e8aa08954fb1bb7bfa (diff)
downloadRustAndDust-2c4d6504abbd51a177aa173dde6ebd37fe765754.zip
RustAndDust-2c4d6504abbd51a177aa173dde6ebd37fe765754.tar.gz
Position: can set width and height
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Position.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/Position.java b/core/src/ch/asynk/tankontank/game/hud/Position.java
index 4f490bd..6f8e520 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Position.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Position.java
@@ -115,6 +115,15 @@ public enum Position
return r;
}
+ private static int hudWidth = Gdx.graphics.getWidth();
+ private static int hudHeight = Gdx.graphics.getHeight();
+
+ public static void update(int width, int height)
+ {
+ hudWidth = width;
+ hudHeight = height;
+ }
+
public float getX(float width)
{
float x;
@@ -127,15 +136,15 @@ public enum Position
case TOP_CENTER:
case MIDDLE_CENTER:
case BOTTOM_CENTER:
- x = ((Gdx.graphics.getWidth() - width) / 2);
+ x = ((hudWidth - width) / 2);
break;
case TOP_RIGHT:
case MIDDLE_RIGHT:
case BOTTOM_RIGHT:
- x = (Gdx.graphics.getWidth() - width - Hud.OFFSET);
+ x = (hudWidth - width - Hud.OFFSET);
break;
default:
- x = ((Gdx.graphics.getWidth() - width) / 2);
+ x = ((hudWidth - width) / 2);
break;
}
return x;
@@ -148,12 +157,12 @@ public enum Position
case TOP_LEFT:
case TOP_CENTER:
case TOP_RIGHT:
- y = (Gdx.graphics.getHeight() - height - Hud.OFFSET);
+ y = (hudHeight - height - Hud.OFFSET);
break;
case MIDDLE_LEFT:
case MIDDLE_CENTER:
case MIDDLE_RIGHT:
- y = ((Gdx.graphics.getHeight() - height) / 2);
+ y = ((hudHeight - height) / 2);
break;
case BOTTOM_LEFT:
case BOTTOM_CENTER:
@@ -161,7 +170,7 @@ public enum Position
y = Hud.OFFSET;
break;
default:
- y = ((Gdx.graphics.getHeight() - height) / 2);
+ y = ((hudHeight - height) / 2);
break;
}
return y;