Magic_Game/Easy2D/Action/ActionDelay.cpp

41 lines
650 B
C++
Raw Normal View History

2017-09-27 17:56:28 +08:00
#include "..\easy2d.h"
ActionDelay::ActionDelay(float duration)
{
setInterval(UINT(duration * 1000));
}
ActionDelay::~ActionDelay()
{
}
ActionDelay * ActionDelay::copy() const
2017-09-27 17:56:28 +08:00
{
return new ActionDelay(m_nMilliSeconds / 1000.0f);
2017-09-27 17:56:28 +08:00
}
void ActionDelay::_init()
{
// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
QueryPerformanceCounter(&m_nLast);
}
bool ActionDelay::_exec(LARGE_INTEGER nNow)
{
if (m_bStop) return true;
if (!m_bRunning) return false;
// <20>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>
if (nNow.QuadPart - m_nLast.QuadPart > m_nAnimationInterval.QuadPart)
{
return true;
}
return false;
}
void ActionDelay::_reset()
{
// <20><><EFBFBD>¼<EFBFBD>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
QueryPerformanceCounter(&m_nLast);
}