Magic_Game/core/Transition/TransitionFade.cpp

62 lines
1.2 KiB
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\e2dtransition.h"
#include "..\e2dnode.h"
2018-04-17 01:11:56 +08:00
e2d::TransitionFade::TransitionFade(double duration)
: TransitionBase(0)
2018-05-08 17:40:36 +08:00
, _fFadeOutDuration(max(duration / 2, 0))
, _fFadeInDuration(max(duration / 2, 0))
, _bFadeOutTransioning(true)
{
}
2018-04-17 01:11:56 +08:00
e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration)
: TransitionBase(0)
2018-05-08 17:40:36 +08:00
, _fFadeOutDuration(max(fadeOutDuration, 0))
, _fFadeInDuration(max(fadeInDuration, 0))
, _bFadeOutTransioning(true)
{
2018-04-17 01:11:56 +08:00
}
2018-01-30 16:45:38 +08:00
2018-04-17 11:41:33 +08:00
void e2d::TransitionFade::_init(Scene * prev, Scene * next)
{
TransitionBase::_init(prev, next);
2018-05-08 17:40:36 +08:00
if (_pPrevScene)
2018-04-17 11:41:33 +08:00
{
2018-05-08 17:40:36 +08:00
_bFadeOutTransioning = true;
_fDuration = _fFadeOutDuration;
2018-04-17 11:41:33 +08:00
}
else
{
2018-05-08 17:40:36 +08:00
_bFadeOutTransioning = false;
_fDuration = _fFadeInDuration;
2018-04-17 11:41:33 +08:00
}
2018-05-08 17:40:36 +08:00
_sPrevLayerParam.opacity = 1;
_sNextLayerParam.opacity = 0;
2018-04-17 11:41:33 +08:00
}
2018-04-17 01:11:56 +08:00
void e2d::TransitionFade::_updateCustom()
{
2018-05-08 17:40:36 +08:00
if (_bFadeOutTransioning)
{
2018-05-08 17:40:36 +08:00
_sPrevLayerParam.opacity = float(1 - _fRateOfProgress);
if (_fRateOfProgress >= 1)
{
2018-05-08 17:40:36 +08:00
_bFadeOutTransioning = false;
_fDuration = _fFadeInDuration;
_fLast = Time::getTotalTime();
}
2018-01-30 16:45:38 +08:00
}
else
{
2018-05-08 17:40:36 +08:00
_sNextLayerParam.opacity = float(_fRateOfProgress);
if (_fRateOfProgress >= 1)
2017-10-21 19:09:31 +08:00
{
2018-01-30 16:45:38 +08:00
this->_stop();
2017-10-21 19:09:31 +08:00
}
}
}
void e2d::TransitionFade::_reset()
{
}