summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-14 01:10:19 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-14 01:10:19 +0200
commit3eba81f5330c0540bedd6bf3b5d320a4ba6d6e85 (patch)
tree7034bf4ad549b25f49cc4329715f6931303c9809 /core
parentf11240a49bcaee2841a468fcd25466d43b30365b (diff)
downloadRustAndDust-3eba81f5330c0540bedd6bf3b5d320a4ba6d6e85.zip
RustAndDust-3eba81f5330c0540bedd6bf3b5d320a4ba6d6e85.tar.gz
add HexMap#centerActorOn(Actor actor, int col, int row)
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/actors/HexMap.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/actors/HexMap.java b/core/src/ch/asynk/tankontank/actors/HexMap.java
index 559aeef..a6ee636 100644
--- a/core/src/ch/asynk/tankontank/actors/HexMap.java
+++ b/core/src/ch/asynk/tankontank/actors/HexMap.java
@@ -1,6 +1,7 @@
package ch.asynk.tankontank.actors;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.math.Vector2;
@@ -27,6 +28,13 @@ public class HexMap extends Image
this.rows = rows;
}
+ public void centerActorOn(Actor actor, int col, int row)
+ {
+ int x = x0 + (int) ((col * w) + ((w - actor.getWidth()) / 2));
+ int y = y0 + (int) ((row * H) + ((h - actor.getWidth()) / 2));
+ actor.setPosition(x, y);
+ }
+
public void selectCell(float cx, float cy)
{
// compute row