Hi @eXpl0it3r and thanks for your answer!
Either your posted code doesn't match what you've implemented...
Yes, the real code is a little bit complicated than what I presented here and that's why simplified it a bit in order to present the issue in a more clear way but I think logically it presents what I wrote on my real code.
or this line shouldn't compile.
soundsPly->play(resMan->getSoundBuffers().soundBuffers[0]);
getSoundBuffers() returns a vector, so you can't be accessing a property called soundBuffers.
ResourcesManager::getSoundBuffers() returns a vector to the private member in the same class:
std::vector<sf::SoundBuffer> soundBuffersso I don't see why it shouldn't compile. But anyway that is not the issue here...
Hard to say now, what your actual code is, but if getSoundBuffers really does return a std::vector<sf::SoundBuffer>, you're always return a copy of the the whole vector, which then only exists temporarily and will be deleted after the call to play() is finished.
So the temporary sound buffer copy gets destroyed, before it's actually played.
To fix this, you'd need to return a reference to the sound buffer.
OK, changed the declaration to
std::vector<sf::SoundBuffer>& getSoundBuffers(); and now the getter returns a reference to the vector of buffers but still no sound...
Additionally, I highly recommend to not misuse the singleton pattern for glorified globals. Instead use dependency injection, meaning to pass the resource manager and sound play via constructor to as few classes as possible.
OK, I'll try to refactor this but it will take some time as the Resource manager is used on many places... It's highly possible I to have some question to your instruction and will ask you later...
Thanks again for your directions!