Hi,
i have a problem when trying to play few sounds simultaneously.
I am currently using this method:
SoundManager.h
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <vector>
#include <map>
enum SoundsNames {Explosion};
class SoundManager
{
std::vector<sf::Sound> sounds;
std::map<SoundsNames, sf::SoundBuffer> soundBuffers;
float soundsVolume;
public:
SoundManager();
void playSound(SoundsNames soundName);
};
SoundManager.cpp
#include "SoundManager.h"
SoundManager::SoundManager()
{
soundBuffers[SoundsNames::Explosion].loadFromFile("Sounds/Explosion.wav");
soundsVolume = 100;
}
void SoundManager::playSound(SoundsNames soundName)
{
sounds.push_back(sf::Sound(soundBuffers[soundName]));
sounds[sounds.size() - 1].setVolume(soundsVolume);
sounds[sounds.size() - 1].play();
}
When i use playSound() function after Player does specific action, it plays sound properly. But the problem is, that when i use playSound() and then after a short time (when the sound hasn't finished yet) use it again, the new sound of course starts, but that one which hasn't finished yet can't be heard (it just stops).
Is there any method to solve this?
Thanks in advance for all replies.
seba174