diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-12 16:53:50 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-12 16:53:50 +0100 |
commit | 8e313b2a0df743045dc5d3a45993b86d0b19f894 (patch) | |
tree | cfc943a7e01e98714299d726fc59216c9c2a020e /core/src/ch/asynk/rustanddust | |
parent | 6641ee0944cbe2397962b74729373958f63cfab8 (diff) | |
download | RustAndDust-8e313b2a0df743045dc5d3a45993b86d0b19f894.zip RustAndDust-8e313b2a0df743045dc5d3a45993b86d0b19f894.tar.gz |
Widget: all positioning calls go through setPosition(int, int, int, int)
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/Widget.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/ui/Widget.java b/core/src/ch/asynk/rustanddust/ui/Widget.java index 4ae8afd..8dfa029 100644 --- a/core/src/ch/asynk/rustanddust/ui/Widget.java +++ b/core/src/ch/asynk/rustanddust/ui/Widget.java @@ -38,15 +38,15 @@ public abstract class Widget implements Disposable, Drawable public void setPosition(Rectangle r) { - rect.set(r); + rect.set(r.x, r.x, r.width, r.height); } public void setPosition(float x, float y) { - rect.x = x; - rect.y = y; + rect.set(x, y, rect.width, rect.height); } + // override this if needed public void setPosition(float x, float y, float w, float h) { rect.set(x, y, w, h); @@ -54,8 +54,7 @@ public abstract class Widget implements Disposable, Drawable public void setPosition(Position position) { - this.position = position; - setParent(this.parent); + setPosition(position, this.parent); } public void setPosition(Position position, Widget parent) @@ -75,7 +74,7 @@ public abstract class Widget implements Disposable, Drawable rect.y = position.getY(parent, rect.height); } // might trigger something if overriden - setPosition(rect.x, rect.y); + setPosition(rect.x, rect.y, rect.width, rect.height); } public boolean hit(float x, float y) |