コード例 #1
0
ファイル: Animation.cpp プロジェクト: ecraven/pioneer
	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;
		}
	}