I’m not a user of LibGDX, but the procedure I follow might be the same, because I employ a resource loader that loads the resources asynchronously too. First of all, I define a class called [icode]Resources[/icode] and store all my references in it.
public class Resources
{
public static class Programs
{
public static Program SPRITE_PROGRAM;
public static Program FONT_PROGRAM;
}
public static class Textures
{
public static Texture BACKGROUND;
public static Texture CLOUDS;
public static Texture GROUND;
public static Texture BULLET;
public static Texture BLOCKS_SHEET;
public static Texture AMOEBAM_SHEET;
public static Texture ENEMY_SHEET;
public static Texture AMOEBAM_SHOOT_SHEET;
public static Texture LOGO;
public static Texture EXIT;
public static Texture AMOEBAM_ROLL;
}
public static class Sounds
{
public static ALBuffer MUSIC;
public static ALSource EXPLOSION;
public static ALSource SHOOT;
}
public static class Animations
{
public static Animation AMOEBAM;
public static Animation AMOEBAM_SMALL;
public static Animation WATER;
public static Animation AMOEBAM_SHOOT_START;
public static Animation AMOEBAM_SHOOT_STOP;
public static Animation ENEMY;
}
public static class CollisionTags
{
public static final CollisionTag GROUND = new CollisionTag();
public static final CollisionTag AMOEBAM = new CollisionTag();
public static final CollisionTag BULLET = new CollisionTag();
public static final CollisionTag ENEMY = new CollisionTag();
public static final CollisionTag EXIT = new CollisionTag();
public static final CollisionTag WATER = new CollisionTag();
}
public static class Levels
{
public static Level LEVEL_1;
public static Level LEVEL_2;
public static Level LEVEL_3;
public static Level LEVEL_4;
public static Level LEVEL_5;
public static Level LEVEL_6;
public static Level LEVEL_7;
public static Level LEVEL_8;
public static Level LEVEL_9;
public static Level LEVEL_10;
}
}
My resource loader loads the defined resources too, and it gives a long handle to get them back once handled. Once they are loaded, I just copy them to these references and I can use them anytime. For example, when I want to draw the background, I can just say
renderer.draw(Resources.Textures.BACKGROUND, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
And it works just fine. The resource loader still keeps the resources in the HashMap, which will be released at the end. These are just references and this is how I do for my games. The above source is actually from my game Amoebam, my LD entry.