summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/engine/gfx/animations/DiceAnimation.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Bg.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Engagement.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Label.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/LabelImage.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Msg.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/OkCancel.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Patch.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Statistics.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Widget.java18
10 files changed, 28 insertions, 20 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/DiceAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/DiceAnimation.java
index 56d12ba..50defd6 100644
--- a/core/src/ch/asynk/tankontank/engine/gfx/animations/DiceAnimation.java
+++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/DiceAnimation.java
@@ -78,7 +78,7 @@ public class DiceAnimation implements Animation, Drawable
return DICE_DIMENSION;
}
- public void set(float x, float y)
+ public void setPosition(float x, float y)
{
this.x = x;
this.y = y;
diff --git a/core/src/ch/asynk/tankontank/game/hud/Bg.java b/core/src/ch/asynk/tankontank/game/hud/Bg.java
index 411683a..8e0bc4e 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Bg.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Bg.java
@@ -11,7 +11,7 @@ public class Bg extends Widget
{
super();
this.region = region;
- set(0, 0, region.getRegionWidth(), region.getRegionHeight());
+ setPosition(0, 0, region.getRegionWidth(), region.getRegionHeight());
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/hud/Engagement.java b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
index 4a95f38..9180a26 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Engagement.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
@@ -80,7 +80,7 @@ public class Engagement extends Patch implements Animation
float width = (attackImg.getWidth() + (2 * d1Animation.getWidth()) + attack.getWidth() + w + (4 * HSPACING) + (2 * PADDING));
float x = position.getX(width);
float y = position.getY(height);
- set(x, y, width, height);
+ setPosition(x, y, width, height);
okBtn.setPosition((x + width - okBtn.getWidth() + OK_OFFSET), (y - OK_OFFSET));
@@ -122,11 +122,11 @@ public class Engagement extends Patch implements Animation
// hud.notify("Ace re-roll");
roll2 = true;
float h = (getHeight() + d1Animation.getHeight() + VSPACING);
- set(getX(), getY(), getWidth(), h);
- d3Animation.set(d1Animation.getX(), d1Animation.getY());
- d4Animation.set(d2Animation.getX(), d2Animation.getY());
- d1Animation.set(d1Animation.getX(), (d1Animation.getY() + d1Animation.getHeight() + VSPACING));
- d2Animation.set(d2Animation.getX(), (d2Animation.getY() + d2Animation.getHeight() + VSPACING));
+ setPosition(getX(), getY(), getWidth(), h);
+ d3Animation.setPosition(d1Animation.getX(), d1Animation.getY());
+ d4Animation.setPosition(d2Animation.getX(), d2Animation.getY());
+ d1Animation.setPosition(d1Animation.getX(), (d1Animation.getY() + d1Animation.getHeight() + VSPACING));
+ d2Animation.setPosition(d2Animation.getX(), (d2Animation.getY() + d2Animation.getHeight() + VSPACING));
}
public boolean hit(float x, float y)
diff --git a/core/src/ch/asynk/tankontank/game/hud/Label.java b/core/src/ch/asynk/tankontank/game/hud/Label.java
index 0b6001e..2c603c6 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Label.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Label.java
@@ -34,7 +34,7 @@ public class Label extends Widget
public void setPosition(float x, float y)
{
TextBounds b = font.getMultiLineBounds((text == null) ? "" : text);
- set(x, y, (b.width + (2 * padding)), (b.height + (2 * padding)));
+ setPosition(x, y, (b.width + (2 * padding)), (b.height + (2 * padding)));
this.rx = x + (padding);
this.ry = (y + padding + b.height);
}
diff --git a/core/src/ch/asynk/tankontank/game/hud/LabelImage.java b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
index bcfd23b..f0c9c4e 100644
--- a/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
+++ b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java
@@ -36,7 +36,7 @@ public class LabelImage extends Bg
public void setPosition(float x, float y)
{
- set(x, y, getWidth(), getHeight());
+ setPosition(x, y, getWidth(), getHeight());
label.setPosition(labelPosition.getX(this, label.getWidth()), labelPosition.getY(this, label.getHeight()));
}
diff --git a/core/src/ch/asynk/tankontank/game/hud/Msg.java b/core/src/ch/asynk/tankontank/game/hud/Msg.java
index 5939796..ce1bfa1 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Msg.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Msg.java
@@ -59,7 +59,7 @@ public class Msg extends Label implements Animation
this.elapsed = 0f;
write(text);
setPosition(position.getX(getWidth()), position.getY(getHeight()));
- bg.set(rect);
+ bg.setPosition(rect);
}
public void write(String text, float duration)
@@ -68,7 +68,7 @@ public class Msg extends Label implements Animation
this.visible = true;
this.elapsed = 0f;
write(text);
- bg.set(rect);
+ bg.setPosition(rect);
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/hud/OkCancel.java b/core/src/ch/asynk/tankontank/game/hud/OkCancel.java
index 51495ce..084e868 100644
--- a/core/src/ch/asynk/tankontank/game/hud/OkCancel.java
+++ b/core/src/ch/asynk/tankontank/game/hud/OkCancel.java
@@ -52,7 +52,7 @@ public class OkCancel extends Patch
width = w2;
float x = position.getX(width);
float y = position.getY(height);
- set(x, y, width, height);
+ setPosition(x, y, width, height);
okBtn.setPosition((x + width - okBtn.getWidth() - PADDING), (y + PADDING));
cancelBtn.setPosition((okBtn.getX() - cancelBtn.getWidth() - HSPACING), okBtn.getY());
diff --git a/core/src/ch/asynk/tankontank/game/hud/Patch.java b/core/src/ch/asynk/tankontank/game/hud/Patch.java
index d5b6caa..4ea0764 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Patch.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Patch.java
@@ -11,7 +11,7 @@ public class Patch extends Widget
{
super();
this.patch = patch;
- set(0, 0, patch.getTotalWidth(), patch.getTotalHeight());
+ setPosition(0, 0, patch.getTotalWidth(), patch.getTotalHeight());
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/hud/Statistics.java b/core/src/ch/asynk/tankontank/game/hud/Statistics.java
index 19b5018..51eef6f 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Statistics.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Statistics.java
@@ -44,7 +44,7 @@ public class Statistics extends Patch
if (w2 > width) width = w2;
float x = position.getX(width);
float y = position.getY(height);
- set(x, y, width, height);
+ setPosition(x, y, width, height);
okBtn.setPosition((x + width - okBtn.getWidth() + OK_OFFSET), (y - OK_OFFSET));
diff --git a/core/src/ch/asynk/tankontank/game/hud/Widget.java b/core/src/ch/asynk/tankontank/game/hud/Widget.java
index aa99607..d277cd0 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Widget.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Widget.java
@@ -11,12 +11,14 @@ public abstract class Widget implements Disposable, Drawable
public boolean blocked;
public boolean visible;
protected Rectangle rect;
+ protected Position position;
protected Widget()
{
this.blocked = false;
this.visible = true;
this.rect = new Rectangle(0, 0, 0, 0);
+ this.position = Position.MIDDLE_CENTER;
}
public float getX() { return rect.x; }
@@ -24,20 +26,26 @@ public abstract class Widget implements Disposable, Drawable
public float getWidth() { return rect.width; }
public float getHeight() { return rect.height; }
- public void set(Rectangle base)
+ public void setPosition(float x, float y)
+ {
+ rect.x = x;
+ rect.y = y;
+ }
+ public void setPosition(Rectangle base)
{
rect.set(base);
}
- public void set(float x, float y, float w, float h)
+ public void setPosition(float x, float y, float w, float h)
{
rect.set(x, y, w, h);
}
- public void setPosition(float x, float y)
+ public void setPosition(Position position)
{
- rect.x = x;
- rect.y = y;
+ this.position = position;
+ rect.x = position.getX(rect.width);
+ rect.y = position.getY(rect.height);
}
public boolean hit(float x, float y)