diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-31 20:15:52 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-31 20:15:52 +0100 |
commit | 6f0d00c76e5ec970af3b14df948cb7598f78fd94 (patch) | |
tree | ac392d6350dac14de470749064446ddcfe0a3594 /core/src | |
parent | 18d0e63a79131ef553a18ae82e78d33c11779957 (diff) | |
download | RustAndDust-6f0d00c76e5ec970af3b14df948cb7598f78fd94.zip RustAndDust-6f0d00c76e5ec970af3b14df948cb7598f78fd94.tar.gz |
GameScreen: use only one SpriteBatch instance
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/screens/GameScreen.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index e8dc6f2..130c393 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -33,8 +33,7 @@ public class GameScreen implements Screen private final GameCamera cam; - private final SpriteBatch mapBatch; - private final SpriteBatch hudBatch; + private final SpriteBatch batch; private ShapeRenderer debugShapes = null; private final TankOnTank game; @@ -53,11 +52,10 @@ public class GameScreen implements Screen this.game = game; this.blocked = false; + this.batch = new SpriteBatch(); this.ctrl = new Ctrl(game, game.config.battle); this.cam = new GameCamera(ctrl.map.getWidth(), ctrl.map.getHeight(), ZOOM_OUT_MAX, ZOOM_IN_MAX); - this.mapBatch = new SpriteBatch(); - this.hudBatch = new SpriteBatch(); if (DEBUG) this.debugShapes = new ShapeRenderer(); Gdx.input.setInputProcessor(getMultiplexer()); @@ -138,10 +136,10 @@ public class GameScreen implements Screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // cam.update(); - mapBatch.setProjectionMatrix(cam.combined); - mapBatch.begin(); - ctrl.map.draw(mapBatch); - mapBatch.end(); + batch.setProjectionMatrix(cam.combined); + batch.begin(); + ctrl.map.draw(batch); + batch.end(); if (DEBUG) { @@ -153,10 +151,10 @@ public class GameScreen implements Screen debugShapes.end(); } - hudBatch.setProjectionMatrix(cam.getHudMatrix()); - hudBatch.begin(); - ctrl.hud.draw(hudBatch, DEBUG); - hudBatch.end(); + batch.setProjectionMatrix(cam.getHudMatrix()); + batch.begin(); + ctrl.hud.draw(batch, DEBUG); + batch.end(); if (DEBUG) { Gdx.gl.glEnable(GL20.GL_BLEND); @@ -180,8 +178,7 @@ public class GameScreen implements Screen public void dispose() { // TankOnTank.debug("GameScreen", "dispose()"); - mapBatch.dispose(); - hudBatch.dispose(); + batch.dispose(); ctrl.dispose(); if (DEBUG) debugShapes.dispose(); } |