I've seen many a time in source code, things like this [well, this is more of a pseudo C++ idea of mine]
type defshared_ptr ResourcePtr;// for ease
ResourcePtr sound1 = resourceManager.Get("boom.ogg");
sound1->Play();
ResourcePtr sprite = resourceManager.Get("sprite.png");
I was just wondering how useful a class like this was, something that:
- Loaded media files
- Stored them in memory
- Did this at the start of a level - loading screen.
- Cleaned up
Rather than having a system of:
- Resources are held by entities only, or loose.
- Responsible for own load into memory.
The first is a 'manager' as such; something I feel indicates it's wrong to use. However, it allows for something like a vector of resource names to be passed, rather than having to scramble around finding everything that needs to be loaded.