Ok, so I'm trying to make a simple Resource Manager that holds all my resources (Images, Music, Fonts, etc).
The problem I am getting is when I ask for a music, I get an error with the NonCopyable thing (which threw me off at first until I realized that it was the Music, not really a Thread that I had created).
here is my code for the resource manager (Kind of cannibalized from tutorials and other posts on this forum):
//function for loading the music
void ResourceManager::loadMusic(const std::string& name, const std::string& filepath)
{
// Only load image if key does not already exist (no duplicate images)
if(Music.find(name) == Music.end())
{
Music[name] = new sf::Music();
Music[name]->OpenFromFile(filepath);//load image from the file
Music[name]->SetLoop(true);
}
}
//function for returning the music requested
const sf::Music& ResourceManager::getMusic(const std::string& name)
{
return *Music[name];
}
//call from main that asks for the music, Resources being a ResourceManager
const sf::Music MenuMusic=Resources.getMusic("FlatOut.ogg");
I'm kind of new to C++ (have had only about a semester-ish of it) but have extensive experience with Java.
Should I have the getMusic() function return a pointer instead? I'm a little bit weary with pointers (I still can't get into the habit of using the -> operator...i know i'm weird).