From cde5813835a5c61fff1c556346170400d1b66960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 19 Sep 2014 15:47:14 +0200 Subject: Drawable: add drawDebug(ShapeRenderer), call it from Layer drawDebug(ShapeRenderer) --- core/src/ch/asynk/tankontank/engine/Layer.java | 10 ++++++++++ core/src/ch/asynk/tankontank/engine/gfx/AbstractDrawable.java | 4 ++++ core/src/ch/asynk/tankontank/engine/gfx/Drawable.java | 3 +++ 3 files changed, 17 insertions(+) diff --git a/core/src/ch/asynk/tankontank/engine/Layer.java b/core/src/ch/asynk/tankontank/engine/Layer.java index 76f99c0..203c469 100644 --- a/core/src/ch/asynk/tankontank/engine/Layer.java +++ b/core/src/ch/asynk/tankontank/engine/Layer.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.utils.viewport.Viewport; import ch.asynk.tankontank.engine.gfx.Node; @@ -100,6 +101,15 @@ public class Layer } } + public void drawDebug(ShapeRenderer debugShapes) + { + debugShapes.setProjectionMatrix(viewport.getCamera().combined); + debugShapes.begin(); + for (int i = 0, n = nodes.size(); i < n; i++) + nodes.get(i).drawDebug(debugShapes); + debugShapes.end(); + } + public void clear() { for (int i = 0, n = nodes.size(); i < n; i++) diff --git a/core/src/ch/asynk/tankontank/engine/gfx/AbstractDrawable.java b/core/src/ch/asynk/tankontank/engine/gfx/AbstractDrawable.java index 5d4705c..bfafb38 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/AbstractDrawable.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/AbstractDrawable.java @@ -1,6 +1,7 @@ package ch.asynk.tankontank.engine.gfx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public abstract class AbstractDrawable implements Drawable { @@ -24,6 +25,9 @@ public abstract class AbstractDrawable implements Drawable } @Override + public void drawDebug(ShapeRenderer debugShapes) {} + + @Override public float getWidth() { return w; diff --git a/core/src/ch/asynk/tankontank/engine/gfx/Drawable.java b/core/src/ch/asynk/tankontank/engine/gfx/Drawable.java index 8b700df..075c33d 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/Drawable.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/Drawable.java @@ -1,6 +1,7 @@ package ch.asynk.tankontank.engine.gfx; import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.utils.Disposable; public interface Drawable extends Disposable @@ -26,4 +27,6 @@ public interface Drawable extends Disposable public void setCoords(float x, float y, int r); public void draw(Batch batch, float parentAlpha); + + public void drawDebug(ShapeRenderer debugShapes); } -- cgit v1.1-2-g2b99