diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-20 21:36:47 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-20 21:36:47 +0100 |
commit | 4adf13571e9ddc119adea434cfdc514d0d80a9c6 (patch) | |
tree | a8165499d0efe107217dbc5d1f671c320a45ae1a /core | |
parent | d084a35f4c7f20a9f706ec7f31cf69054e675b6b (diff) | |
download | RustAndDust-4adf13571e9ddc119adea434cfdc514d0d80a9c6.zip RustAndDust-4adf13571e9ddc119adea434cfdc514d0d80a9c6.tar.gz |
add ui/Button
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/Button.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/ui/Button.java b/core/src/ch/asynk/rustanddust/ui/Button.java new file mode 100644 index 0000000..be54d5b --- /dev/null +++ b/core/src/ch/asynk/rustanddust/ui/Button.java @@ -0,0 +1,49 @@ +package ch.asynk.rustanddust.ui; + +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.NinePatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; + +public class Button extends Patch +{ + private Label label; + + public Button(String text, BitmapFont font, NinePatch patch, float padding) + { + super(patch); + label = new Label(font, padding); + label.write(text); + setPosition(label.getX(), label.getY(), label.getWidth(), label.getHeight()); + } + + @Override + public void setPosition(float x, float y, float w, float h) + { + rect.set(x, y, w, h); + if (label != null) label.setPosition(x, y); + } + + @Override + public void dispose() + { + super.dispose(); + label.dispose(); + } + + @Override + public void draw(Batch batch) + { + if (!visible) return; + super.draw(batch); + label.draw(batch); + } + + @Override + public void drawDebug(ShapeRenderer shapes) + { + if (!visible) return; + super.drawDebug(shapes); + label.drawDebug(shapes); + } +} |