2018-05-08 20:03:29 +08:00
|
|
|
#include "..\e2daction.h"
|
2018-05-24 00:58:16 +08:00
|
|
|
#include "..\e2dnode.h"
|
2018-05-08 20:03:29 +08:00
|
|
|
|
|
|
|
|
|
2018-07-28 20:06:27 +08:00
|
|
|
e2d::ScaleBy::ScaleBy(float duration, float scale)
|
2018-05-22 22:29:42 +08:00
|
|
|
: FiniteTimeAction(duration)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
|
|
|
|
_deltaX = scale;
|
|
|
|
|
_deltaY = scale;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-28 20:06:27 +08:00
|
|
|
e2d::ScaleBy::ScaleBy(float duration, float scaleX, float scaleY)
|
2018-05-22 22:29:42 +08:00
|
|
|
: FiniteTimeAction(duration)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
|
|
|
|
_deltaX = scaleX;
|
|
|
|
|
_deltaY = scaleY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::ScaleBy::_init()
|
|
|
|
|
{
|
2018-05-22 22:29:42 +08:00
|
|
|
FiniteTimeAction::_init();
|
2018-05-10 00:58:43 +08:00
|
|
|
|
2018-05-08 20:03:29 +08:00
|
|
|
if (_target)
|
|
|
|
|
{
|
2018-08-23 16:37:44 +08:00
|
|
|
_startScaleX = _target->scaleX();
|
|
|
|
|
_startScaleY = _target->scaleY();
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::ScaleBy::_update()
|
|
|
|
|
{
|
2018-05-22 22:29:42 +08:00
|
|
|
FiniteTimeAction::_update();
|
2018-05-08 20:03:29 +08:00
|
|
|
|
2018-05-10 00:58:43 +08:00
|
|
|
if (_target)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
2018-08-23 16:37:44 +08:00
|
|
|
_target->scale(_startScaleX + _deltaX * _delta, _startScaleY + _deltaY * _delta);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e2d::ScaleBy * e2d::ScaleBy::clone() const
|
|
|
|
|
{
|
2018-07-06 12:59:32 +08:00
|
|
|
return new (e2d::autorelease) ScaleBy(_duration, _deltaX, _deltaY);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e2d::ScaleBy * e2d::ScaleBy::reverse() const
|
|
|
|
|
{
|
2018-07-06 12:59:32 +08:00
|
|
|
return new (e2d::autorelease) ScaleBy(_duration, -_deltaX, -_deltaY);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|