2017-09-27 17:56:28 +08:00
|
|
|
|
#include "..\easy2d.h"
|
|
|
|
|
|
|
|
|
|
|
|
ActionOpacityBy::ActionOpacityBy(float duration, float opacity) :
|
|
|
|
|
|
Animation(duration)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_nVariation = opacity;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ActionOpacityBy::~ActionOpacityBy()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionOpacityBy::_init()
|
|
|
|
|
|
{
|
|
|
|
|
|
Animation::_init();
|
2017-10-06 02:32:33 +08:00
|
|
|
|
m_nBeginVal = m_pTargetSprite->getOpacity();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-08 12:30:45 +08:00
|
|
|
|
void ActionOpacityBy::_exec(LARGE_INTEGER nNow)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
if (Animation::_isDelayEnough(nNow))
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
float scale = float(m_nDuration) / m_nTotalDuration;
|
|
|
|
|
|
// <20>ƶ<EFBFBD> Sprite
|
2017-10-06 02:32:33 +08:00
|
|
|
|
m_pTargetSprite->setOpacity(m_nBeginVal + m_nVariation * scale);
|
2017-09-27 17:56:28 +08:00
|
|
|
|
// <20>ж϶<D0B6><CFB6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
2017-09-30 16:18:45 +08:00
|
|
|
|
if (_isEnd())
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
this->stop();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionOpacityBy::_reset()
|
|
|
|
|
|
{
|
|
|
|
|
|
Animation::_reset();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-30 16:18:45 +08:00
|
|
|
|
ActionOpacityBy * ActionOpacityBy::copy() const
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-09-30 16:18:45 +08:00
|
|
|
|
return new ActionOpacityBy(m_nMilliSeconds / 1000.0f, m_nVariation);
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ActionOpacityBy * ActionOpacityBy::reverse() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return new ActionOpacityBy(m_nTotalDuration / 1000.0f, -m_nVariation);
|
|
|
|
|
|
}
|