Exemple #1
0
    spSoundInstance SoundPlayer::continuePlay(Resource* res, Channel* ch, const PlayOptions& opt)
    {
        spSoundInstance s = prepareSound(res, ch, opt);
        if (!s)
            return 0;

        _sounds.push_back(s);
        ch->continuePlay(s->_desc);

        return s;
    }
bool SoundManager::playSound(std::string const& filename)
{
	std::string fullPath = "resources/sounds/" + filename;
    auto s = prepareSound(fullPath);
    if (s != nullptr)
    {
        s->play();
        return true;
    }
    return false;
}
Exemple #3
0
    spSoundInstance SoundPlayer::play(Resource* res, const PlayOptions& opt)
    {
        Channel* ch = SoundSystem::instance->getFreeChannel();
        spSoundInstance s = prepareSound(res, ch, opt);
        if (!s)
            return 0;

        _sounds.push_back(s);
        ch->play(s->_desc);

        return s;
    }
Exemple #4
0
    spSoundInstance SoundPlayer::play(const std::string& id, const PlayOptions& opt)
    {
        if (!_resources)
            return 0;

        ResSound* res = _resources->getT<ResSound>(id);
        if (!res)
            return 0;

        Channel* ch = SoundSystem::instance->getFreeChannel();
        spSoundInstance s = prepareSound(res, ch, opt);
        if (!s)
            return 0;

        _sounds.push_back(s);
        ch->play(s->_desc);

        return s;
    }
bool SoundManager::playRandSound(std::string const& filename)
{
	short maxNumberOfSounds = 0;
	if (filename == "sword/swipe") maxNumberOfSounds = 13;
	/*
		more
	*/

	short i = 0;
	srand(time(0));
	i = rand() % maxNumberOfSounds + 1;

	std::ostringstream numb;
	numb << i;
	std::string fullPath = "resources/sounds/" + filename + "/" + numb.str() + ".wav";
	auto s = prepareSound(fullPath);
	if (s != nullptr)
	{
		s->play();
		return true;
	}
	return false;
}