Magic_Game/core/Action/ActionOpacityBy.cpp

40 lines
732 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::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) :
ActionGradual(duration)
{
2018-05-08 17:40:36 +08:00
_nVariation = opacity;
}
void e2d::ActionOpacityBy::_init()
{
ActionGradual::_init();
2018-05-08 17:40:36 +08:00
if (_pTarget)
{
2018-05-08 17:40:36 +08:00
_nBeginVal = _pTarget->getOpacity();
}
}
void e2d::ActionOpacityBy::_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;
}
2018-01-30 16:45:38 +08:00
// <20><><EFBFBD>ýڵ<C3BD>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>
2018-05-08 17:40:36 +08:00
_pTarget->setOpacity(_nBeginVal + _nVariation * _fRateOfProgress);
}
e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const
{
2018-05-08 17:40:36 +08:00
return new ActionOpacityBy(_fDuration, _nVariation);
}
e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const
{
2018-05-08 17:40:36 +08:00
return new ActionOpacityBy(_fDuration, -_nVariation);
}