2017-09-27 17:56:28 +08:00
|
|
|
|
#include "..\easy2d.h"
|
2017-10-10 01:14:03 +08:00
|
|
|
|
#include "..\Win\winbase.h"
|
2017-09-27 17:56:28 +08:00
|
|
|
|
|
|
|
|
|
|
ActionDelay::ActionDelay(float duration)
|
|
|
|
|
|
{
|
2017-10-10 01:14:03 +08:00
|
|
|
|
setInterval(LONGLONG(duration * 1000));
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ActionDelay::~ActionDelay()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-30 16:18:45 +08:00
|
|
|
|
ActionDelay * ActionDelay::copy() const
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-10 01:14:03 +08:00
|
|
|
|
return new ActionDelay(m_nAnimationInterval / 1000.0f);
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionDelay::_init()
|
|
|
|
|
|
{
|
2017-10-08 13:26:42 +08:00
|
|
|
|
Action::_init();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
|
2017-10-10 01:14:03 +08:00
|
|
|
|
m_nLast = steady_clock::now();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-10 01:14:03 +08:00
|
|
|
|
void ActionDelay::_exec(steady_clock::time_point nNow)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
// <20>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
2017-10-10 01:14:03 +08:00
|
|
|
|
if (duration_cast<milliseconds>(nNow - m_nLast).count() > m_nAnimationInterval)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
this->stop();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionDelay::_reset()
|
|
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
Action::_reset();
|
2017-10-10 01:14:03 +08:00
|
|
|
|
// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
|
|
|
|
|
|
m_nLast = steady_clock::now();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|