Audio manager
Similar to what we did for textures and fonts, we're going to need a way to manage sf::SoundBuffer
instances easily. Luckily, our ResourceManager
class is there to make it extremely convenient, so let's create the AudioManager.h
file and define the way sound buffers are set up:
class AudioManager : public ResourceManager< AudioManager, sf::SoundBuffer> { public: AudioManager() : ResourceManager("audio.cfg"){} sf::SoundBuffer* Load(const std::string& l_path){ sf::SoundBuffer* sound = new sf::SoundBuffer(); if (!sound->loadFromFile( Utils::GetWorkingDirectory() + l_path)) { delete sound; sound = nullptr; std::cerr << "! Failed to load sound: " << l_path << std::endl; } return sound; } };
As you can tell already, the sound interface is pretty much exactly the same as that of textures or fonts. Similar to the previous resource managers, we also provide a file...