Magic_Game/core/Transition/FadeTransition.cpp

43 lines
662 B
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\e2dtransition.h"
#include "..\e2dnode.h"
2018-07-28 20:06:27 +08:00
e2d::FadeTransition::FadeTransition(float duration)
: Transition(duration)
{
2018-04-17 01:11:56 +08:00
}
2018-01-30 16:45:38 +08:00
2018-08-02 00:27:45 +08:00
bool e2d::FadeTransition::init(Scene * prev, Scene * next)
2018-04-17 11:41:33 +08:00
{
2018-08-02 00:27:45 +08:00
if (Transition::init(prev, next))
{
_outLayerParam.opacity = 1;
_inLayerParam.opacity = 0;
return true;
}
return false;
2018-04-17 11:41:33 +08:00
}
2018-08-02 00:27:45 +08:00
void e2d::FadeTransition::update()
2018-04-17 01:11:56 +08:00
{
2018-08-02 00:27:45 +08:00
Transition::update();
if (_delta < 0.5)
{
2018-07-28 20:06:27 +08:00
_outLayerParam.opacity = 1 - _delta * 2;
_inLayerParam.opacity = 0;
2018-01-30 16:45:38 +08:00
}
else
{
_outLayerParam.opacity = 0;
2018-07-28 20:06:27 +08:00
_inLayerParam.opacity = (_delta - 0.5f) * 2;
if (_delta >= 1)
2017-10-21 19:09:31 +08:00
{
2018-08-02 00:27:45 +08:00
this->stop();
2017-10-21 19:09:31 +08:00
}
}
}
2018-08-02 00:27:45 +08:00
void e2d::FadeTransition::reset()
{
}