summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-02 10:27:39 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-02 10:27:39 +0100
commitb22f2b184e63acc86ef5d9ef49f9c1f0b5cdf693 (patch)
treef7f8122d688dfe907190776ba4785cbb96f286ba /core/src
parentb223877a7feb632dfa38cc60c72d1566ae4f8b40 (diff)
downloadRustAndDust-b22f2b184e63acc86ef5d9ef49f9c1f0b5cdf693.zip
RustAndDust-b22f2b184e63acc86ef5d9ef49f9c1f0b5cdf693.tar.gz
Position: support bottom,left offset
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/ui/Position.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/core/src/ch/asynk/tankontank/ui/Position.java b/core/src/ch/asynk/tankontank/ui/Position.java
index f1708c6..1257cb6 100644
--- a/core/src/ch/asynk/tankontank/ui/Position.java
+++ b/core/src/ch/asynk/tankontank/ui/Position.java
@@ -115,36 +115,45 @@ public enum Position
return r;
}
+ private static int hudLeft = 0;
+ private static int hudBottom = 0;
private static int hudWidth = Gdx.graphics.getWidth();
private static int hudHeight = Gdx.graphics.getHeight();
public static void update(int width, int height)
{
+ update(0, 0, width, height);
+ }
+
+ public static void update(int left, int bottom, int width, int height)
+ {
+ hudLeft = left;
+ hudBottom = bottom;
hudWidth = width;
hudHeight = height;
}
public float getX(float width)
{
- float x;
+ float x = hudLeft;
switch(this) {
case TOP_LEFT:
case MIDDLE_LEFT:
case BOTTOM_LEFT:
- x = Hud.OFFSET;
+ x += Hud.OFFSET;
break;
case TOP_CENTER:
case MIDDLE_CENTER:
case BOTTOM_CENTER:
- x = ((hudWidth - width) / 2);
+ x += ((hudWidth - width) / 2);
break;
case TOP_RIGHT:
case MIDDLE_RIGHT:
case BOTTOM_RIGHT:
- x = (hudWidth - width - Hud.OFFSET);
+ x += (hudWidth - width - Hud.OFFSET);
break;
default:
- x = ((hudWidth - width) / 2);
+ x += ((hudWidth - width) / 2);
break;
}
return x;
@@ -152,25 +161,25 @@ public enum Position
public float getY(float height)
{
- float y;
+ float y = hudBottom;
switch(this) {
case TOP_LEFT:
case TOP_CENTER:
case TOP_RIGHT:
- y = (hudHeight - height - Hud.OFFSET);
+ y += (hudHeight - height - Hud.OFFSET);
break;
case MIDDLE_LEFT:
case MIDDLE_CENTER:
case MIDDLE_RIGHT:
- y = ((hudHeight - height) / 2);
+ y += ((hudHeight - height) / 2);
break;
case BOTTOM_LEFT:
case BOTTOM_CENTER:
case BOTTOM_RIGHT:
- y = Hud.OFFSET;
+ y += Hud.OFFSET;
break;
default:
- y = ((hudHeight - height) / 2);
+ y += ((hudHeight - height) / 2);
break;
}
return y;
@@ -178,7 +187,7 @@ public enum Position
public float getX(Widget widget, float width)
{
- float x;
+ float x = 0;
switch(this) {
case TOP_LEFT:
case MIDDLE_LEFT:
@@ -204,7 +213,7 @@ public enum Position
public float getY(Widget widget, float height)
{
- float y;
+ float y = 0;
switch(this) {
case TOP_LEFT:
case TOP_CENTER: