Magic_Game/core/Action/Action.cpp

103 lines
1.3 KiB
C++
Raw Normal View History

#include "..\eaction.h"
#include "..\emanager.h"
2017-10-19 00:50:04 +08:00
e2d::Action::Action()
2018-01-30 16:45:38 +08:00
: 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
{
2018-03-06 09:56:17 +08:00
ActionManager::__add(this);
2017-10-19 00:50:04 +08:00
}
e2d::Action::~Action()
2017-10-19 00:50:04 +08:00
{
2018-03-06 09:56:17 +08:00
ActionManager::__remove(this);
2017-10-19 00:50:04 +08:00
}
bool e2d::Action::isRunning()
2017-10-19 00:50:04 +08:00
{
return m_bRunning;
2017-10-19 00:50:04 +08:00
}
bool e2d::Action::_isEnding()
2017-10-19 00:50:04 +08:00
{
return m_bEnding;
}
2018-03-06 09:56:17 +08:00
void e2d::Action::setTarget(Node* pTarget)
2017-10-19 00:50:04 +08:00
{
2018-03-06 09:56:17 +08:00
if (pTarget)
{
m_bRunning = true;
m_pTarget = pTarget;
this->reset();
}
2017-10-19 00:50:04 +08:00
}
void e2d::Action::resume()
2017-10-19 00:50:04 +08:00
{
m_bRunning = true;
m_fLast = Time::getTotalTime();
2017-10-19 00:50:04 +08:00
}
void e2d::Action::pause()
2017-10-19 00:50:04 +08:00
{
m_bRunning = false;
}
void e2d::Action::stop()
2017-10-19 00:50:04 +08:00
{
m_bEnding = true;
}
2018-03-06 09:56:17 +08:00
e2d::String e2d::Action::getName() const
{
return m_sName;
}
void e2d::Action::setName(String name)
2018-03-06 09:56:17 +08:00
{
m_sName = name;
}
e2d::Action * e2d::Action::reverse() const
2017-10-19 00:50:04 +08:00
{
ASSERT(false, "Action cannot be reversed!");
2017-10-19 00:50:04 +08:00
return nullptr;
}
e2d::Node * e2d::Action::getTarget()
2017-10-19 00:50:04 +08:00
{
return m_pTarget;
}
void e2d::Action::_init()
2017-10-19 00:50:04 +08:00
{
m_bInit = true;
2017-10-21 19:09:31 +08:00
// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
m_fLast = Time::getTotalTime();
2017-10-19 00:50:04 +08:00
}
void e2d::Action::_update()
2017-11-03 12:51:01 +08:00
{
if (!m_bInit)
{
_init();
}
}
void e2d::Action::reset()
2017-10-19 00:50:04 +08:00
{
m_bInit = false;
m_bEnding = false;
m_fLast = Time::getTotalTime();
}
void e2d::Action::_resetTime()
{
m_fLast = Time::getTotalTime();
2017-10-19 00:50:04 +08:00
}