summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-22 17:21:29 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-22 17:21:29 +0200
commit075e6b5a9a8e7dea0252bb2972364b5cc1954a91 (patch)
tree877f2fb0fda9923b64bbc7ec69868e02d67e5d04 /core/src/ch/asynk
parent31a06d9af7554a0a802c7e8afaae045c4eed8bd3 (diff)
downloadRustAndDust-075e6b5a9a8e7dea0252bb2972364b5cc1954a91.zip
RustAndDust-075e6b5a9a8e7dea0252bb2972364b5cc1954a91.tar.gz
Pawn mignt have overlays
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java51
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java1
2 files changed, 51 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 3061346..2bc78e3 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -4,11 +4,15 @@ import java.util.ArrayDeque;
import com.badlogic.gdx.utils.Disposable;
+import com.badlogic.gdx.graphics.g2d.Batch;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3;
import ch.asynk.tankontank.engine.gfx.Image;
+import ch.asynk.tankontank.engine.gfx.StackedImages;
import ch.asynk.tankontank.engine.gfx.animations.MoveToAnimation;
import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation;
import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence;
@@ -17,11 +21,14 @@ public abstract class Pawn extends Image implements Disposable
{
private static final float MOVE_TIME = 0.3f;
+ private StackedImages overlays;
private ArrayDeque<Vector3> path = new ArrayDeque<Vector3>();
- public Pawn(TextureRegion region)
+ public Pawn(TextureRegion region, TextureAtlas atlas)
{
super(region);
+ if (atlas != null)
+ this.overlays = new StackedImages(atlas);
}
public Vector3 getLastPosition()
@@ -65,4 +72,46 @@ public abstract class Pawn extends Image implements Disposable
return seq;
}
+
+ public boolean hasOverlayEnabled()
+ {
+ if (overlays == null) return false;
+ return overlays.isEnabled();
+ }
+
+ public boolean enableOverlay(int i, boolean enable)
+ {
+ if (overlays == null) return false;
+ overlays.enable(i, enable);
+ if (enable) return true;
+ return hasOverlayEnabled();
+ }
+
+ @Override
+ public void translate(float x, float y)
+ {
+ super.translate(x, y);
+ if (overlays != null) overlays.translate(x, y);
+ }
+
+ @Override
+ public void setPosition(float x, float y, float z)
+ {
+ super.setPosition(x, y, z);
+ if (overlays != null) overlays.setPosition(x, y, z);
+ }
+
+ @Override
+ public void draw(Batch batch, float parentAlpha)
+ {
+ super.draw(batch, parentAlpha);
+ if (overlays != null) overlays.draw(batch, parentAlpha);
+ }
+
+ @Override
+ public void drawDebug(ShapeRenderer debugShapes)
+ {
+ super.drawDebug(debugShapes);
+ if (overlays != null) overlays.drawDebug(debugShapes);
+ }
}
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 31a822d..3a144b2 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -1,6 +1,7 @@
package ch.asynk.tankontank.game;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import ch.asynk.tankontank.engine.Pawn;