void AnimationController::Update() { PROFILE_SCOPED(); const Uint32 now = SDL_GetTicks(); for (auto i = m_animations.begin(); i != m_animations.end();) { Animation *animation = (*i).first.Get(); Uint32 start = (*i).second; float remaining = 0.0f; if (!animation->IsCompleted()) remaining = animation->Update(float(now - start) / 1000.f); if (animation->IsCompleted()) { Animation *nextAnimation = animation->GetNext(); if (nextAnimation) { assert(!animation->IsRunning()); m_animations.push_back(std::make_pair(RefCountedPtr<Animation>(nextAnimation), now - Uint32(-remaining * 1000.0f))); nextAnimation->Running(); } m_animations.erase(i++); } else ++i; } }
static int l_attr_running(lua_State *l) { Animation *a = LuaObject<UI::Animation>::CheckFromLua(1); lua_pushboolean(l, a->IsRunning()); return 1; }