Magic_Game/core/Action/OpacityBy.cpp

39 lines
655 B
C++
Raw Normal View History

#include "..\e2daction.h"
2018-05-24 00:58:16 +08:00
#include "..\e2dnode.h"
2018-07-28 20:06:27 +08:00
e2d::OpacityBy::OpacityBy(float duration, float opacity)
2018-05-22 22:29:42 +08:00
: FiniteTimeAction(duration)
{
_deltaVal = opacity;
}
void e2d::OpacityBy::_init()
{
2018-05-22 22:29:42 +08:00
FiniteTimeAction::_init();
2018-05-10 00:58:43 +08:00
if (_target)
{
_startVal = _target->opacity();
}
}
void e2d::OpacityBy::_update()
{
2018-05-22 22:29:42 +08:00
FiniteTimeAction::_update();
2018-05-10 00:58:43 +08:00
if (_target)
{
_target->opacity(_startVal + _deltaVal * _delta);
}
}
e2d::OpacityBy * e2d::OpacityBy::clone() const
{
return new (e2d::autorelease) OpacityBy(_duration, _deltaVal);
}
e2d::OpacityBy * e2d::OpacityBy::reverse() const
{
return new (e2d::autorelease) OpacityBy(_duration, -_deltaVal);
}