Magic_Game/core/Action/ActionMoveBy.cpp

41 lines
673 B
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\e2daction.h"
2018-01-30 16:45:38 +08:00
2018-02-27 21:07:43 +08:00
e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) :
ActionGradual(duration)
2018-01-30 16:45:38 +08:00
{
2018-05-08 17:40:36 +08:00
_MoveVec = vector;
2018-01-30 16:45:38 +08:00
}
void e2d::ActionMoveBy::_init()
2018-01-30 16:45:38 +08:00
{
ActionGradual::_init();
2018-05-08 17:40:36 +08:00
if (_pTarget)
2018-01-30 16:45:38 +08:00
{
2018-05-08 17:40:36 +08:00
_BeginPos = _pTarget->getPos();
2018-01-30 16:45:38 +08:00
}
}
void e2d::ActionMoveBy::_update()
2018-01-30 16:45:38 +08:00
{
ActionGradual::_update();
2018-01-30 16:45:38 +08:00
2018-05-08 17:40:36 +08:00
if (_pTarget == nullptr)
2018-01-30 16:45:38 +08:00
{
this->stop();
return;
}
// <20>ƶ<EFBFBD><C6B6>ڵ<EFBFBD>
2018-05-08 17:40:36 +08:00
_pTarget->setPos(_BeginPos + _MoveVec * _fRateOfProgress);
2018-01-30 16:45:38 +08:00
}
e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const
2018-01-30 16:45:38 +08:00
{
2018-05-08 17:40:36 +08:00
return new ActionMoveBy(_fDuration, _MoveVec);
2018-01-30 16:45:38 +08:00
}
e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const
2018-01-30 16:45:38 +08:00
{
2018-05-08 17:40:36 +08:00
return new ActionMoveBy(_fDuration, -_MoveVec);
2018-01-30 16:45:38 +08:00
}