Magic_Game/core/Action/Action.cpp

88 lines
1.2 KiB
C++
Raw Normal View History

2017-10-19 00:50:04 +08:00
#include "..\eactions.h"
2018-02-06 15:34:47 +08:00
#include "..\emanagers.h"
2017-10-19 00:50:04 +08:00
2018-01-30 16:45:38 +08:00
e2d::EAction::EAction()
: m_bRunning(false)
, m_bEnding(false)
, m_bInit(false)
, m_pTarget(nullptr)
, m_pParentScene(nullptr)
, m_fLast(0)
2017-10-19 00:50:04 +08:00
{
}
e2d::EAction::~EAction()
{
2018-02-06 15:34:47 +08:00
EActionManager::__destroyAction(this);
2017-10-19 00:50:04 +08:00
}
bool e2d::EAction::isRunning()
{
return m_bRunning;
2017-10-19 00:50:04 +08:00
}
bool e2d::EAction::_isEnding()
2017-10-19 00:50:04 +08:00
{
return m_bEnding;
}
2018-02-06 15:34:47 +08:00
void e2d::EAction::startWith(ENode* pTarget)
2017-10-19 00:50:04 +08:00
{
2018-02-06 15:34:47 +08:00
m_bRunning = true;
m_pTarget = pTarget;
2017-10-19 00:50:04 +08:00
}
void e2d::EAction::resume()
{
m_bRunning = true;
2018-01-30 16:45:38 +08:00
m_fLast = ETime::getTotalTime();
2017-10-19 00:50:04 +08:00
}
void e2d::EAction::pause()
{
m_bRunning = false;
}
void e2d::EAction::stop()
{
m_bEnding = true;
}
e2d::EAction * e2d::EAction::reverse() const
{
2018-02-03 22:04:43 +08:00
ASSERT(false, "EAction cannot be reversed!");
2017-10-19 00:50:04 +08:00
return nullptr;
}
e2d::ENode * e2d::EAction::getTarget()
{
return m_pTarget;
}
void e2d::EAction::_init()
{
m_bInit = true;
2017-10-21 19:09:31 +08:00
// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
2018-01-30 16:45:38 +08:00
m_fLast = ETime::getTotalTime();
2017-10-19 00:50:04 +08:00
}
void e2d::EAction::_update()
2017-11-03 12:51:01 +08:00
{
if (!m_bInit)
{
_init();
}
}
2018-02-06 15:34:47 +08:00
void e2d::EAction::reset()
2017-10-19 00:50:04 +08:00
{
m_bInit = false;
m_bEnding = false;
2018-01-30 16:45:38 +08:00
m_fLast = ETime::getTotalTime();
}
void e2d::EAction::_resetTime()
{
2018-01-30 16:45:38 +08:00
m_fLast = ETime::getTotalTime();
2017-10-19 00:50:04 +08:00
}