Cache assets

This commit is contained in:
Matt Low 2020-01-02 20:51:50 +04:00
parent d21a4b8c1d
commit ecaf86a57a

View File

@ -15,6 +15,10 @@ public class Assets {
private AssetManager manager;
private Texture levelBackground;
private Texture levelWinBackground;
private Texture menuBackground;
public TextureRegion[][] level;
public TextureRegion[][] deathAnimation;
public TextureRegion[][] ghosts;
@ -31,6 +35,7 @@ public class Assets {
public Sound return_base;
public Sound siren, siren_fast, siren_faster, siren_fastest;
private BitmapFont font;
public Assets() {
this.manager = new AssetManager();
@ -77,6 +82,11 @@ public class Assets {
// finish loading assets from disk
manager.finishLoading();
this.font = manager.get("fonts/joystix.ttf", BitmapFont.class);
levelBackground = manager.get("level_background.png", Texture.class);
levelWinBackground = manager.get("level_background_win.png", Texture.class);
menuBackground = manager.get("menu_background.png", Texture.class);
// cache our texture regions
level = TextureRegion.split(manager.get("sprites/level.png", Texture.class), 8, 8);
deathAnimation = TextureRegion.split(manager.get("sprites/death.png", Texture.class), 16, 16);
@ -103,15 +113,15 @@ public class Assets {
}
public Texture getLevelBackground() {
return manager.get("level_background.png", Texture.class);
return levelBackground;
}
public Texture getLevelWinBackground() {
return manager.get("level_background_win.png", Texture.class);
return levelWinBackground;
}
public Texture getMenuBackground() {
return manager.get("menu_background.png", Texture.class);
return menuBackground;
}
public Texture getLogo() {
@ -119,7 +129,7 @@ public class Assets {
}
public BitmapFont getFont() {
return manager.get("fonts/joystix.ttf", BitmapFont.class);
return font;
}
public void dispose() {