-
Notifications
You must be signed in to change notification settings - Fork 7
Loading Resources
acoox edited this page May 23, 2021
·
2 revisions
Resources are managed by the Resource Service which loads and stores resources. To spread out the loading times, resources should be loaded in batches as needed.
Currently, the Resource Service supports Textures
, Texture Atlases
, Music
and Sounds
, but can be easily extended to support more resource types.
Resources should be loaded and unloaded into ResourceService
using the corresponding load method. The following example is for textures.
private static final String[] forestTextures = {
"images/grass_1.png",
"images/grass_2.png",
"images/grass_3.png"
};
// load
public void create() {
ServiceLocator.getResourceService().loadTextures(forestTextures);
}
// unload
public void dispose() {
ServiceLocator.getResourceService().unloadAssets(forestTextures);
}
ResourceService
is essentially a wrapper class for libgdx's AssetManager. The main reasons for having a wrapper class are to make it easier to load resources in batches, support the addition of loading screens, and to improve logging.