summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-07-06 12:14:41 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2018-07-06 12:14:41 +0200
commit21405a878478592281e077981c2d155b2c5af36f (patch)
tree731545c583b0bf4da426098c63b215603d5ed1dc /core/src
parentc4f8ea5d16db402dd300d22b5e4795586068204c (diff)
downloadgdx-boardgame-21405a878478592281e077981c2d155b2c5af36f.zip
gdx-boardgame-21405a878478592281e077981c2d155b2c5af36f.tar.gz
GameScreen : do not pass a Rectangle on draw, use resize if needed
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/zproject/Board.java3
-rw-r--r--core/src/ch/asynk/zproject/Hud.java9
-rw-r--r--core/src/ch/asynk/zproject/screens/GameScreen.java5
3 files changed, 12 insertions, 5 deletions
diff --git a/core/src/ch/asynk/zproject/Board.java b/core/src/ch/asynk/zproject/Board.java
index a9b52fa..22b7e74 100644
--- a/core/src/ch/asynk/zproject/Board.java
+++ b/core/src/ch/asynk/zproject/Board.java
@@ -2,7 +2,6 @@ package ch.asynk.zproject;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Disposable;
public class Board implements Disposable
@@ -29,7 +28,7 @@ public class Board implements Disposable
return map.getHeight();
}
- public void draw(Batch batch, Rectangle viewPort)
+ public void draw(Batch batch)
{
batch.draw(map, 0, 0);
}
diff --git a/core/src/ch/asynk/zproject/Hud.java b/core/src/ch/asynk/zproject/Hud.java
index b1cf5ea..d013d7b 100644
--- a/core/src/ch/asynk/zproject/Hud.java
+++ b/core/src/ch/asynk/zproject/Hud.java
@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.Disposable;
public class Hud implements Disposable
{
+ private final Rectangle rect;
private final Sprite hud;
private final GlyphLayout glyphLayout;
private final BitmapFont font20;
@@ -17,6 +18,7 @@ public class Hud implements Disposable
public Hud(final Assets assets)
{
+ this.rect = new Rectangle(0, 0, 0, 0);
this.hud = new Sprite(assets.getTexture(assets.CORNER));
this.glyphLayout = new GlyphLayout();
font20 = assets.getFont(assets.FONT_20);
@@ -28,7 +30,12 @@ public class Hud implements Disposable
hud.getTexture().dispose();
}
- public void draw(Batch batch, final Rectangle rect)
+ public void resize(float width, float height)
+ {
+ rect.set(0, 0, width, height);
+ }
+
+ public void draw(Batch batch)
{
float right = rect.x + rect.width - hud.getWidth();
float top = rect.y + rect.height - hud.getHeight();
diff --git a/core/src/ch/asynk/zproject/screens/GameScreen.java b/core/src/ch/asynk/zproject/screens/GameScreen.java
index 8447f12..606c7c3 100644
--- a/core/src/ch/asynk/zproject/screens/GameScreen.java
+++ b/core/src/ch/asynk/zproject/screens/GameScreen.java
@@ -66,13 +66,13 @@ public class GameScreen implements Screen
camera.applyMapViewport();
batch.setProjectionMatrix(camera.combined);
batch.begin();
- board.draw(batch, camera.getViewport());
+ board.draw(batch);
batch.end();
camera.applyHudViewport();
batch.setProjectionMatrix(camera.getHudMatrix());
batch.begin();
- hud.draw(batch, camera.getHud());
+ hud.draw(batch);
batch.end();
}
@@ -81,6 +81,7 @@ public class GameScreen implements Screen
if (paused) return;
ZProject.debug("GameScreen", String.format("resize (%d,%d)",width, height));
camera.updateViewport(width, height);
+ hud.resize(camera.getHud().width, camera.getHud().height);
}
@Override public void dispose()