Magic_Game/core/Action/ActionRotateBy.cpp

41 lines
721 B
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\e2daction.h"
2018-02-27 21:07:43 +08:00
e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) :
ActionGradual(duration)
{
2018-05-08 17:40:36 +08:00
_nVariation = rotation;
}
void e2d::ActionRotateBy::_init()
{
ActionGradual::_init();
2018-05-08 17:40:36 +08:00
if (_pTarget)
{
2018-05-08 17:40:36 +08:00
_nBeginVal = _pTarget->getRotation();
}
}
void e2d::ActionRotateBy::_update()
{
ActionGradual::_update();
2017-11-03 12:51:01 +08:00
2018-05-08 17:40:36 +08:00
if (_pTarget == nullptr)
{
this->stop();
return;
}
2017-11-03 12:51:01 +08:00
2018-01-30 16:45:38 +08:00
// <20><>ת<EFBFBD>ڵ<EFBFBD>
2018-05-08 17:40:36 +08:00
_pTarget->setRotation(_nBeginVal + _nVariation * _fRateOfProgress);
}
e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const
{
2018-05-08 17:40:36 +08:00
return new ActionRotateBy(_fDuration, _nVariation);
}
e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const
{
2018-05-08 17:40:36 +08:00
return new ActionRotateBy(_fDuration, -_nVariation);
}