hgeResourceManager
Script-based resource loading and management.
Overview
The hgeResourceManager class provides script-based resource management for HGE applications. Instead of loading each resource individually in code, you define resources in a script file and load them all at once.
Benefits
- Centralized definition — All resources defined in one place
- Easy modification — Change paths or parameters without recompiling
- Automatic dependency management — Resources can reference each other
- Clean code — Game code doesn't need resource paths hardcoded
Script Format
Resource scripts use a simple text format:
Texture background
{
filename=images/bg.png
}
Sprite player
{
texture=background
rect=0,0,64,64
hotspot=32,32
}
Sound shoot
{
filename=sounds/shoot.wav
}
Music bgm
{
filename=music/level1.ogg
}
Usage
hgeResourceManager *rm = new hgeResourceManager("resources.res");
// Get resources by name
HTEXTURE tex = rm->GetTexture("background");
hgeSprite *spr = rm->GetSprite("player");
HEFFECT snd = rm->GetEffect("shoot");
HSTREAM mus = rm->GetStream("bgm");
Resource Types
The resource manager supports:
- Texture — Image files
- Sprite — Texture regions with rendering parameters
- Animation — Animated sprite sequences
- Font — Bitmap fonts
- Particle — Particle system definitions
- Distortion — Distortion mesh configurations
- String — Text strings (for localization)
- Sound — Sound effect files
- Music — Streaming audio files