Exemplo n.º 1
0
    void ParticleManager::Update()
    {
        if (!_paused)
        {
            _currentTime += EffectsLibrary::GetUpdateTime();
            ++_currentTick;
            TLFXLOG(PARTICLES, ("tick: %d time: %f", _currentTick, GetCurrentTime()));
            for (int el = 0; el < _effectLayers; ++el)
            {
                // Effect
                for (auto it =_effects[el].begin(); it != _effects[el].end(); )
                {
                    if (!(*it)->Update())
                    {
                        //RemoveEffect(*it);
                        auto x = *it;
                        delete x;
                        _effects[el].erase(it++);
                    }
                    else
                        ++it;
                }
            }

            _oldOriginX = _originX;
            _oldOriginY = _originY;
            _oldOriginZ = _originZ;
        }
    }
Exemplo n.º 2
0
    bool Particle::Update()
    {
        TLFXLOG(PARTICLES, ("particle #%p update", this));

        Capture();

        if (_emitter->IsDying() || _emitter->IsOneShot() || _dead)
            _releaseSingleParticle = true;

        if (_emitter->IsSingleParticle() && !_releaseSingleParticle)
        {
            _age = _particleManager->GetCurrentTime() - _dob;
            if (_age > _lifeTime)
            {
                _age = 0;
                _dob = _particleManager->GetCurrentTime();
            }
        }
        else
        {
            _age = _particleManager->GetCurrentTime() - _dob;
        }

        base::Update();

        if (_age > _lifeTime || _dead == 2)                 // if dead=2 then that means its reached the end of the line (in kill mode) for line traversal effects
        {
            _dead = 1;
            if (_children.empty())
            {
                _particleManager->ReleaseParticle(this);
                if (_emitter->IsGroupParticles())
                    _emitter->GetParentEffect()->RemoveInUse(_layer, this);

                Reset();
                return false;               // RemoveChild
            }
            else
            {
                _emitter->ControlParticle(this);
                KillChildren();
            }

            return true;
        }

        _emitter->ControlParticle(this);
        return true;
    }