Beispiel #1
0
	void SpriteList::update(Float32 elapsedTime)
	{
		// Update everything
		for (Sprite& sprite : sprites)
		{
			sprite.update(elapsedTime);
		}

		// Delete sprites with finished animations
		auto sprite = sprites.begin();
		while (sprite != sprites.end())
		{
			if (sprite->getLooping() == AnimationLooping::OnceAndRemove && sprite->isFinished())
			{
				sprite = sprites.erase(sprite);
			}
			else
			{
				++sprite;
			}
		}
	}
Beispiel #2
0
void FModSound::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & FileFieldMask)
    {
        if(!boost::filesystem::exists(getFile()))
		{
			SWARNING << "FModSound: error loading sound from file: " << getFile().string() << " This file does not exist." << std::endl;
		}
		else
        {
            FMOD_RESULT      result;
            FMOD_MODE soundMode(FMOD_DEFAULT);
            if(getEnable3D())
            {
                soundMode |= FMOD_3D;
            }
            //soundMode |= FMOD_NONBLOCKING;
            if(getLooping() != 0)
            {
                soundMode |= FMOD_LOOP_NORMAL | FMOD_SOFTWARE;
            }
            else
            {
                soundMode |= FMOD_HARDWARE;
            }

            if(getStreaming())
            {
                result = FModSoundManager::the()->getSystem()->createStream(getFile().string().c_str(), soundMode, 0, &_FModSound);		// FMOD_DEFAULT uses the defaults.  These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
            }
            else
            {
                result = FModSoundManager::the()->getSystem()->createSound(getFile().string().c_str(), soundMode, 0, &_FModSound);		// FMOD_DEFAULT uses the defaults.  These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
            }
            FMOD_ERRCHECK(result,"FModSound::changed()");

            if(result != FMOD_OK)
            {
                if(getStreaming())
                {
                    result = FModSoundManager::the()->getSystem()->createStream(getFile().string().c_str(), FMOD_SOFTWARE, 0, &_FModSound);		// FMOD_DEFAULT uses the defaults.  These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
                }
                else
                {
                    result = FModSoundManager::the()->getSystem()->createSound(getFile().string().c_str(), FMOD_SOFTWARE, 0, &_FModSound);		// FMOD_DEFAULT uses the defaults.  These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
                }
            }
            FMOD_ERRCHECK(result,"FModSound::changed()");
        }
    }
    if(whichField & VolumeFieldMask ||
        whichField & PanFieldMask ||
        whichField & FrequencyFieldMask)
    {
        FMOD_RESULT      result;
        result = _FModSound->setDefaults(getFrequency(), getVolume(),getPan(), 128);
        FMOD_ERRCHECK(result,"FModSound::changed()");
    }
    if(whichField & LoopingFieldMask)
    {
        FMOD_RESULT      result;
        result = _FModSound->setLoopCount(getLooping() - 1);
        FMOD_ERRCHECK(result,"FModSound::changed()");
    }
}