2018-05-08 20:03:29 +08:00
|
|
|
#include "..\e2daction.h"
|
|
|
|
|
|
|
|
|
|
|
2018-05-10 14:03:54 +08:00
|
|
|
e2d::RotateBy::RotateBy(double duration, double rotation)
|
|
|
|
|
: ActionGradual(duration)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
|
|
|
|
_deltaVal = rotation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::RotateBy::_init()
|
|
|
|
|
{
|
|
|
|
|
ActionGradual::_init();
|
2018-05-10 00:58:43 +08:00
|
|
|
|
2018-05-08 20:03:29 +08:00
|
|
|
if (_target)
|
|
|
|
|
{
|
|
|
|
|
_startVal = _target->getRotation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::RotateBy::_update()
|
|
|
|
|
{
|
|
|
|
|
ActionGradual::_update();
|
|
|
|
|
|
2018-05-10 00:58:43 +08:00
|
|
|
if (_target)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
2018-05-10 00:58:43 +08:00
|
|
|
_target->setRotation(_startVal + _deltaVal * _delta);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e2d::RotateBy * e2d::RotateBy::clone() const
|
|
|
|
|
{
|
2018-05-10 14:03:54 +08:00
|
|
|
return new (std::nothrow) RotateBy(_duration, _deltaVal);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e2d::RotateBy * e2d::RotateBy::reverse() const
|
|
|
|
|
{
|
2018-05-10 14:03:54 +08:00
|
|
|
return new (std::nothrow) RotateBy(_duration, -_deltaVal);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|