Magic_Game/core/Action/Action.cpp

91 lines
1.2 KiB
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\e2daction.h"
#include "..\e2dmanager.h"
2017-10-19 00:50:04 +08:00
e2d::Action::Action()
: _running(false)
, _done(false)
, _initialized(false)
, _target(nullptr)
, _last(0)
2017-10-19 00:50:04 +08:00
{
2018-07-05 01:09:54 +08:00
ActionManager::getInstance()->__add(this);
2017-10-19 00:50:04 +08:00
}
e2d::Action::~Action()
2017-10-19 00:50:04 +08:00
{
2018-07-05 01:09:54 +08:00
ActionManager::getInstance()->__remove(this);
2017-10-19 00:50:04 +08:00
}
bool e2d::Action::isRunning()
2017-10-19 00:50:04 +08:00
{
return _running;
2017-10-19 00:50:04 +08:00
}
void e2d::Action::resume()
2017-10-19 00:50:04 +08:00
{
_running = true;
2018-07-22 00:41:24 +08:00
_last = Game::getInstance()->getTotalDuration().seconds();
2017-10-19 00:50:04 +08:00
}
void e2d::Action::pause()
2017-10-19 00:50:04 +08:00
{
_running = false;
2017-10-19 00:50:04 +08:00
}
void e2d::Action::stop()
2017-10-19 00:50:04 +08:00
{
_done = true;
2017-10-19 00:50:04 +08:00
}
e2d::String e2d::Action::getName() const
2018-03-06 09:56:17 +08:00
{
return _name;
2018-03-06 09:56:17 +08:00
}
void e2d::Action::setName(const String& name)
2018-03-06 09:56:17 +08:00
{
_name = name;
2018-03-06 09:56:17 +08:00
}
e2d::Node * e2d::Action::getTarget()
2017-10-19 00:50:04 +08:00
{
return _target;
2017-10-19 00:50:04 +08:00
}
void e2d::Action::reset()
{
_initialized = false;
_done = false;
2018-07-22 00:41:24 +08:00
_last = Game::getInstance()->getTotalDuration().seconds();
}
bool e2d::Action::_isDone()
{
return _done;
}
void e2d::Action::_startWithTarget(Node* target)
{
_target = target;
_running = true;
this->reset();
}
void e2d::Action::_init()
2017-10-19 00:50:04 +08:00
{
_initialized = true;
2018-07-22 00:41:24 +08:00
_last = Game::getInstance()->getTotalDuration().seconds();
2017-10-19 00:50:04 +08:00
}
void e2d::Action::_update()
2017-11-03 12:51:01 +08:00
{
if (!_initialized)
{
_init();
}
}
void e2d::Action::_resetTime()
{
}