Can’t say that this is in my place to give advice seeing as I’m sort of a newb myself, but I for one believe that unless you’re not concerned with the memory consumption at all, I would suggest option 2. I actually asked a similar question in the past.
You could make a class meant for loading resources upon request. For instance, in my project, I wrote something along the lines of…
(Keep in mind that I’m programming with Slick2D)
public class Resources
{
HashMap images; // Cached images
String imageLoc; // Folder for images
public Resources()
{
images = new HashMap<String, Image>();
imageLoc = "res/images/";
}
public void getImage(String fileName
{
// Checks for image in cache...
Image image = images.get(fileName);
// If the image was not found in cache...
if(image == null)
{
// Tries to load the image using the file name given, and caches it
try
{
image = new Image(imageLoc + fileName);
images.put(fileName, image);
}
// Fails to load the image... what a sad day...
catch (SlickException e)
{
e.printStackTrace();
}
}
// Gimmeh mah image!
return image;
}
public void release()
{
// All resources are released to save memory
}
}
This code is untested, but it demonstrates the helpfulness of hash maps in some instances. Dunno if this will be useful to you, but I just felt like posting it. I always prefer to make many hash maps for different types of resources, and make a few methods for retrieving the resources like the one above. I also make load methods which load a requested resource while returning nothing serving only as a lightweight version of the get methods.
P.S. Sorry for the sloppyness