diff options
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java | 17 | ||||
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/UiScreen.java | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java index fdceda6..d65c853 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.glutils.HdpiUtils; @@ -19,6 +20,8 @@ import ch.asynk.gdx.boardgame.ui.Root; public abstract class AbstractScreen implements Screen { + private static final boolean DEBUG = false; + private static final float INPUT_DELAY = 0.1f; // filter out touches after gesture private static final float ZOOM_SCROLL_FACTOR = .1f; private static final float ZOOM_GESTURE_FACTOR = .01f; @@ -27,6 +30,8 @@ public abstract class AbstractScreen implements Screen protected final Vector3 boardTouch = new Vector3(); protected final Vector3 hudTouch = new Vector3(); + private ShapeRenderer debugShapes = null; + protected final String dom; protected final GdxBoardTest app; protected final SpriteBatch batch; @@ -50,9 +55,12 @@ public abstract class AbstractScreen implements Screen this.inputDelay = 0f; this.paused = false; + if (DEBUG) this.debugShapes = new ShapeRenderer(); + HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } + protected void drawDebug(ShapeRenderer shapeRenderer) { } protected abstract void draw(SpriteBatch batch); @Override public void render(float delta) { @@ -66,6 +74,15 @@ public abstract class AbstractScreen implements Screen batch.begin(); draw(batch); batch.end(); + + if (DEBUG) { + Gdx.gl.glEnable(GL20.GL_BLEND); + debugShapes.setAutoShapeType(true); + debugShapes.setProjectionMatrix(camera.combined); + debugShapes.begin(); + drawDebug(debugShapes); + debugShapes.end(); + } } @Override public void resize(int width, int height) diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index f94e4f7..8793510 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -3,6 +3,7 @@ package ch.asynk.gdx.boardgame.test; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.OrthographicCamera; import ch.asynk.gdx.boardgame.ui.Alignment; @@ -99,6 +100,11 @@ public class UiScreen extends AbstractScreen root.draw(batch); } + @Override protected void drawDebug(ShapeRenderer shapeRenderer) + { + root.drawDebug(shapeRenderer); + } + private void setButtons(boolean add) { if (add) { |