59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
#include "dl_action.h"
|
||
|
||
#include "render/dl_factory.h"
|
||
#include "system/dl_time.h"
|
||
#include "system/dl_system.h"
|
||
|
||
namespace dl
|
||
{
|
||
|
||
dl::FloatTime Action::GetK()
|
||
{
|
||
FloatTime ret = _cur / _max;
|
||
if (!is_saturate(ret))
|
||
{
|
||
log_err("计算结果不为:[0, 1]!");
|
||
return saturate(ret);
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
#ifndef DL_DISABLE_RENDER
|
||
void ActionManager::ExCreateCurtain(FloatTime t)
|
||
{
|
||
gcSprite spr = g_factory->CreateSpriteDefault();
|
||
spr->SetQuad(createQuad(g_system->GetWindowSize(), false));
|
||
ActionColor* act = new ActionColor(10, [=](ActionColor* act) mutable {
|
||
spr->SetColor(act->GetColor());
|
||
spr->Render();
|
||
});
|
||
act->SetColor({ ColorDef::GREEN, createColor(ColorDef::RED, 0)});
|
||
Add(act);
|
||
}
|
||
#endif
|
||
void ActionManager::_update()
|
||
{
|
||
FloatTime dt = g_time->GetDelta();
|
||
for (auto iter = _allAction.begin(); iter != _allAction.end();)
|
||
{
|
||
Action* act = *iter;
|
||
if (act->_update(dt) || act->IsFinish())
|
||
{
|
||
delete act;
|
||
iter = _allAction.erase(iter);
|
||
continue;
|
||
}
|
||
act->Update();
|
||
++iter;
|
||
}
|
||
}
|
||
|
||
ActionManager::~ActionManager()
|
||
{
|
||
for (auto& iter : _allAction)
|
||
{
|
||
delete iter;
|
||
}
|
||
}
|
||
|
||
} |