SoundUtils.cpp 725 Bytes
//
//  SoundUtils.cpp
//  SteveMaggieCpp
//
//  Created by Katarzyna Kalinowska-Górska on 10.05.2017.
//
//

#include "SoundUtils.h"
#include "MathUtils.h"
#include "SoundsRepo.h"

    unsigned int SoundUtils::playRandomSound(std::string soundFolderPath, std::vector<std::string> soundNames, bool stopEffects){
    
        auto soundsLength = soundNames.size();
        if(soundsLength > 0){
            int randomIndex = MathUtils::getRandomInt(0, (int)soundsLength-1);
            std::string fullSoundPath = soundFolderPath == "" ? soundNames[randomIndex] : soundFolderPath /*+ "/"*/ + soundNames[randomIndex];
            return SoundsRepo::playSound(fullSoundPath, stopEffects);
        }
    
        return 0;
    }