Skip to content

Loading Resources

acoox edited this page May 23, 2021 · 2 revisions

Introduction

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.

Usage

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);
}

Behind the Scenes

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.

Table of Contents

Home

How to Play

Introduction

Game Features

Main Character

Enemies
The Final Boss

Landscape Objects

Shop
Inventory
Achievements
Camera

Crystal

Infrastructure

Audio

User Interfaces Across All Pages
Juicy UI
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)
Map
Day and Night Cycle
Unified Grid System (UGS)
Polishing

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally