Magic_Game/core/Transition/BoxTransition.cpp

48 lines
900 B
C++
Raw Normal View History

2018-05-22 13:49:10 +08:00
#include "..\e2dtransition.h"
#include "..\e2dnode.h"
2018-08-14 00:26:20 +08:00
e2d::BoxTransition::BoxTransition(Scene* scene, float duration)
: Transition(scene, duration)
2018-05-22 13:49:10 +08:00
{
}
2018-08-19 15:11:20 +08:00
bool e2d::BoxTransition::_init(Game * game, Scene * prev)
2018-05-22 13:49:10 +08:00
{
2018-08-19 15:11:20 +08:00
if (Transition::_init(game, prev))
2018-08-02 00:27:45 +08:00
{
_inLayerParam.opacity = 0;
return true;
}
return false;
2018-05-22 13:49:10 +08:00
}
2018-08-14 00:26:20 +08:00
void e2d::BoxTransition::_update()
2018-05-22 13:49:10 +08:00
{
2018-08-14 00:26:20 +08:00
Transition::_update();
2018-08-02 00:27:45 +08:00
2018-05-22 13:49:10 +08:00
if (_delta <= 0.5)
{
_outLayerParam.contentBounds = D2D1::RectF(
2018-07-28 20:06:27 +08:00
_windowSize.width * _delta,
_windowSize.height * _delta,
_windowSize.width * (1 - _delta),
_windowSize.height * (1 - _delta)
2018-05-22 13:49:10 +08:00
);
}
else
{
_outLayerParam.opacity = 0;
_inLayerParam.opacity = 1;
_inLayerParam.contentBounds = D2D1::RectF(
2018-07-28 20:06:27 +08:00
_windowSize.width * (1 - _delta),
_windowSize.height * (1 - _delta),
_windowSize.width * _delta,
_windowSize.height * _delta
2018-05-22 13:49:10 +08:00
);
if (_delta >= 1)
{
2018-08-14 00:26:20 +08:00
this->_stop();
2018-05-22 13:49:10 +08:00
}
}
}