Managing sounds

Due to the limitations on the number of sounds we can have in an application, it's best to have a centralized way of handling and recycling them. This is where the SoundManager class comes in. Let's begin aliasing a data type for sound IDs:

using SoundID = int;

A simple integer type is more than qualified for the job of keeping sounds identified.

Additionally, we'll want to store some information with the sound instance:

struct SoundInfo{
    SoundInfo(const std::string& l_name): m_name(l_name), m_manualPaused(false){}
    std::string m_name;
    bool m_manualPaused;
};

In order to properly deallocate resources when it counts, we're going to want to store the string identifier of the audio file that the sound is using. Keeping track of whether ...

Get SFML Game Development By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.