From d07be94ba960a71174fa178879396fde491b7f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 2 Jan 2015 11:13:57 +0100 Subject: TankOnTank: correctly load/unload maps --- core/src/ch/asynk/tankontank/TankOnTank.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java index 52c16a1..20f600d 100644 --- a/core/src/ch/asynk/tankontank/TankOnTank.java +++ b/core/src/ch/asynk/tankontank/TankOnTank.java @@ -83,10 +83,10 @@ public class TankOnTank extends Game public void loadGameAssets() { - debug("TankOnTank", " load assets : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB"); - // TODO load only needed map - manager.load("data/map_a.png", Texture.class); - manager.load("data/map_b.png", Texture.class); + if (config.battle.getMapType() == Factory.MapType.MAP_A) + manager.load("data/map_a.png", Texture.class); + if (config.battle.getMapType() == Factory.MapType.MAP_B) + manager.load("data/map_b.png", Texture.class); manager.load("data/hex.png", Texture.class); manager.load("data/hud.atlas", TextureAtlas.class); manager.load("data/units.atlas", TextureAtlas.class); @@ -104,14 +104,15 @@ public class TankOnTank extends Game manager.load("sounds/explosion.mp3", Sound.class); manager.load("sounds/explosion_short.mp3", Sound.class); manager.load("sounds/promote.mp3", Sound.class); + debug("TankOnTank", " assets loaded : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB"); } private void unloadGameAssets() { - debug("TankOnTank", "unload assets : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB"); - // TODO load only needed map - manager.unload("data/map_a.png"); - manager.unload("data/map_b.png"); + if (config.battle.getMapType() == Factory.MapType.MAP_A) + manager.unload("data/map_a.png"); + if (config.battle.getMapType() == Factory.MapType.MAP_B) + manager.unload("data/map_b.png"); manager.unload("data/hex.png"); manager.unload("data/hud.atlas"); manager.unload("data/units.atlas"); @@ -129,6 +130,7 @@ public class TankOnTank extends Game manager.unload("sounds/explosion.mp3"); manager.unload("sounds/explosion_short.mp3"); manager.unload("sounds/promote.mp3"); + debug("TankOnTank", " assets unloaded : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB"); } private void loadUiAssets() @@ -144,7 +146,6 @@ public class TankOnTank extends Game { fontB.dispose(); fontW.dispose(); - uiAtlas.dispose(); manager.unload("data/ui.atlas"); } @@ -158,7 +159,6 @@ public class TankOnTank extends Game private void unloadMenuAssets() { - menuAtlas.dispose(); manager.unload("data/map_a.png"); manager.unload("data/menu.atlas"); } @@ -196,6 +196,8 @@ public class TankOnTank extends Game break; } debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() ); + manager.clear(); + manager.dispose(); } // @Override -- cgit v1.1-2-g2b99