2018-04-21 21:24:46 +08:00
|
|
|
#include "..\e2dtransition.h"
|
|
|
|
|
#include "..\e2dnode.h"
|
2017-10-20 00:59:26 +08:00
|
|
|
|
2018-08-14 00:26:20 +08:00
|
|
|
e2d::FadeTransition::FadeTransition(Scene* scene, float duration)
|
|
|
|
|
: Transition(scene, duration)
|
2017-10-20 00:59:26 +08:00
|
|
|
{
|
2018-04-17 01:11:56 +08:00
|
|
|
}
|
2018-01-30 16:45:38 +08:00
|
|
|
|
2018-09-04 22:42:34 +08:00
|
|
|
bool e2d::FadeTransition::Init(Game * game, Scene * prev)
|
2018-04-17 11:41:33 +08:00
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
if (Transition::Init(game, prev))
|
2018-08-02 00:27:45 +08:00
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
out_layer_param_.opacity = 1;
|
|
|
|
|
in_layer_param_.opacity = 0;
|
2018-08-02 00:27:45 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2018-04-17 11:41:33 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-04 22:42:34 +08:00
|
|
|
void e2d::FadeTransition::Update()
|
2018-04-17 01:11:56 +08:00
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
Transition::Update();
|
2018-08-02 00:27:45 +08:00
|
|
|
|
2018-09-04 22:42:34 +08:00
|
|
|
if (delta_ < 0.5)
|
2017-10-20 00:59:26 +08:00
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
out_layer_param_.opacity = 1 - delta_ * 2;
|
|
|
|
|
in_layer_param_.opacity = 0;
|
2018-01-30 16:45:38 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
out_layer_param_.opacity = 0;
|
|
|
|
|
in_layer_param_.opacity = (delta_ - 0.5f) * 2;
|
|
|
|
|
if (delta_ >= 1)
|
2017-10-21 19:09:31 +08:00
|
|
|
{
|
2018-09-04 22:42:34 +08:00
|
|
|
this->Stop();
|
2017-10-21 19:09:31 +08:00
|
|
|
}
|
2017-12-09 15:27:11 +08:00
|
|
|
}
|
|
|
|
|
}
|