Cache assets
This commit is contained in:
parent
d21a4b8c1d
commit
ecaf86a57a
@ -15,6 +15,10 @@ public class Assets {
|
|||||||
|
|
||||||
private AssetManager manager;
|
private AssetManager manager;
|
||||||
|
|
||||||
|
private Texture levelBackground;
|
||||||
|
private Texture levelWinBackground;
|
||||||
|
private Texture menuBackground;
|
||||||
|
|
||||||
public TextureRegion[][] level;
|
public TextureRegion[][] level;
|
||||||
public TextureRegion[][] deathAnimation;
|
public TextureRegion[][] deathAnimation;
|
||||||
public TextureRegion[][] ghosts;
|
public TextureRegion[][] ghosts;
|
||||||
@ -31,6 +35,7 @@ public class Assets {
|
|||||||
public Sound return_base;
|
public Sound return_base;
|
||||||
public Sound siren, siren_fast, siren_faster, siren_fastest;
|
public Sound siren, siren_fast, siren_faster, siren_fastest;
|
||||||
|
|
||||||
|
private BitmapFont font;
|
||||||
|
|
||||||
public Assets() {
|
public Assets() {
|
||||||
this.manager = new AssetManager();
|
this.manager = new AssetManager();
|
||||||
@ -77,6 +82,11 @@ public class Assets {
|
|||||||
// finish loading assets from disk
|
// finish loading assets from disk
|
||||||
manager.finishLoading();
|
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
|
// cache our texture regions
|
||||||
level = TextureRegion.split(manager.get("sprites/level.png", Texture.class), 8, 8);
|
level = TextureRegion.split(manager.get("sprites/level.png", Texture.class), 8, 8);
|
||||||
deathAnimation = TextureRegion.split(manager.get("sprites/death.png", Texture.class), 16, 16);
|
deathAnimation = TextureRegion.split(manager.get("sprites/death.png", Texture.class), 16, 16);
|
||||||
@ -103,15 +113,15 @@ public class Assets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Texture getLevelBackground() {
|
public Texture getLevelBackground() {
|
||||||
return manager.get("level_background.png", Texture.class);
|
return levelBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getLevelWinBackground() {
|
public Texture getLevelWinBackground() {
|
||||||
return manager.get("level_background_win.png", Texture.class);
|
return levelWinBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getMenuBackground() {
|
public Texture getMenuBackground() {
|
||||||
return manager.get("menu_background.png", Texture.class);
|
return menuBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getLogo() {
|
public Texture getLogo() {
|
||||||
@ -119,7 +129,7 @@ public class Assets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BitmapFont getFont() {
|
public BitmapFont getFont() {
|
||||||
return manager.get("fonts/joystix.ttf", BitmapFont.class);
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
Loading…
Reference in New Issue
Block a user