Magic_Game/core/Transition/TransitionMove.cpp

83 lines
1.8 KiB
C++
Raw Normal View History

#include "..\etransition.h"
#include "..\enode.h"
2017-10-21 19:09:31 +08:00
2018-04-17 01:11:56 +08:00
e2d::TransitionMove::TransitionMove(double duration, int direct)
: Transition(duration)
2017-10-21 19:09:31 +08:00
, m_Direct(direct)
{
}
2018-04-17 01:11:56 +08:00
void e2d::TransitionMove::_updateCustom()
{
2018-04-17 01:11:56 +08:00
if (m_pPrevScene)
{
auto root = m_pPrevScene->getRoot();
root->setPos(m_Vector * m_fRateOfProgress);
Point pos = root->getPos();
m_sPrevLayerParam.contentBounds = D2D1::RectF(
float(max(pos.x, 0)),
float(max(pos.y, 0)),
float(min(pos.x + m_WindowSize.width, m_WindowSize.width)),
float(min(pos.y + m_WindowSize.height, m_WindowSize.height))
);
}
if (m_pNextScene)
{
auto root = m_pNextScene->getRoot();
root->setPos(m_NextPos + m_Vector * m_fRateOfProgress);
2018-01-30 16:45:38 +08:00
2018-04-17 01:11:56 +08:00
Point pos = root->getPos();
m_sNextLayerParam.contentBounds = D2D1::RectF(
float(max(pos.x, 0)),
float(max(pos.y, 0)),
float(min(pos.x + m_WindowSize.width, m_WindowSize.width)),
float(min(pos.y + m_WindowSize.height, m_WindowSize.height))
);
}
2018-01-30 16:45:38 +08:00
if (m_fRateOfProgress >= 1)
{
this->_stop();
}
}
2018-04-17 01:11:56 +08:00
void e2d::TransitionMove::_init(Scene * prev, Scene * next)
2017-10-21 19:09:31 +08:00
{
2018-04-17 01:11:56 +08:00
Transition::_init(prev, next);
m_WindowSize = Window::getSize();
double width = m_WindowSize.width;
double height = m_WindowSize.height;
if (m_Direct == Direct::UP)
2017-10-21 19:09:31 +08:00
{
2018-04-17 01:11:56 +08:00
m_Vector = Vector(0, -height);
m_NextPos = Point(0, height);
2017-10-21 19:09:31 +08:00
}
2018-04-17 01:11:56 +08:00
else if (m_Direct == Direct::DOWN)
2017-10-21 19:09:31 +08:00
{
2018-04-17 01:11:56 +08:00
m_Vector = Vector(0, height);
m_NextPos = Point(0, -height);
2017-10-21 19:09:31 +08:00
}
2018-04-17 01:11:56 +08:00
else if (m_Direct == Direct::LEFT)
2017-10-21 19:09:31 +08:00
{
2018-04-17 01:11:56 +08:00
m_Vector = Vector(-width, 0);
m_NextPos = Point(width, 0);
2017-10-21 19:09:31 +08:00
}
2018-04-17 01:11:56 +08:00
else if (m_Direct == Direct::RIGHT)
2017-10-21 19:09:31 +08:00
{
2018-04-17 01:11:56 +08:00
m_Vector = Vector(width, 0);
m_NextPos = Point(-width, 0);
2017-10-21 19:09:31 +08:00
}
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
m_pNextScene->getRoot()->setPos(m_NextPos);
}
2017-10-21 19:09:31 +08:00
void e2d::TransitionMove::_reset()
{
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
m_pNextScene->getRoot()->setPos(0, 0);
2017-10-21 19:09:31 +08:00
}