2018-01-30 16:45:38 +08:00
|
|
|
|
#include "..\ebase.h"
|
2017-12-09 15:27:11 +08:00
|
|
|
|
#include "..\etransitions.h"
|
|
|
|
|
|
|
2018-02-27 21:07:43 +08:00
|
|
|
|
e2d::Transition::Transition(double duration)
|
2017-12-09 15:27:11 +08:00
|
|
|
|
: m_bEnd(false)
|
2018-01-30 16:45:38 +08:00
|
|
|
|
, m_fLast(0)
|
2017-12-09 15:27:11 +08:00
|
|
|
|
, m_fRateOfProgress(0)
|
|
|
|
|
|
, m_pPrevScene(nullptr)
|
|
|
|
|
|
, m_pNextScene(nullptr)
|
|
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
m_fDuration = max(duration, 0);
|
2017-12-09 15:27:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-07 16:37:12 +08:00
|
|
|
|
bool e2d::Transition::isEnding()
|
2017-12-09 15:27:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
return m_bEnd;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-07 16:37:12 +08:00
|
|
|
|
void e2d::Transition::_calcRateOfProgress()
|
2017-12-09 15:27:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
// <20>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
2018-01-30 16:45:38 +08:00
|
|
|
|
if (m_fDuration == 0)
|
2017-12-09 15:27:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_fRateOfProgress = 1;
|
2018-01-30 16:45:38 +08:00
|
|
|
|
return;
|
2017-12-09 15:27:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
// <20><><EFBFBD>㶯<EFBFBD><E3B6AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-02-07 16:37:12 +08:00
|
|
|
|
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1);
|
2017-12-09 15:27:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-07 16:37:12 +08:00
|
|
|
|
void e2d::Transition::_stop()
|
2017-12-09 15:27:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_bEnd = true;
|
|
|
|
|
|
_reset();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-07 16:37:12 +08:00
|
|
|
|
void e2d::Transition::_setTarget(Scene * prev, Scene * next)
|
2017-12-09 15:27:11 +08:00
|
|
|
|
{
|
2018-02-07 16:37:12 +08:00
|
|
|
|
m_fLast = Time::getTotalTime();
|
2017-12-09 15:27:11 +08:00
|
|
|
|
m_pPrevScene = prev;
|
|
|
|
|
|
m_pNextScene = next;
|
|
|
|
|
|
_init();
|
|
|
|
|
|
}
|