细节调整
This commit is contained in:
parent
a18ff4295d
commit
f9181a2080
|
|
@ -2,12 +2,12 @@
|
|||
#include "..\e2dmanager.h"
|
||||
|
||||
e2d::ActionBase::ActionBase()
|
||||
: m_bRunning(false)
|
||||
, m_bEnding(false)
|
||||
, m_bInit(false)
|
||||
, m_pTarget(nullptr)
|
||||
, m_pParentScene(nullptr)
|
||||
, m_fLast(0)
|
||||
: _bRunning(false)
|
||||
, _bEnding(false)
|
||||
, _bInit(false)
|
||||
, _pTarget(nullptr)
|
||||
, _pParentScene(nullptr)
|
||||
, _fLast(0)
|
||||
{
|
||||
ActionManager::__add(this);
|
||||
}
|
||||
|
|
@ -16,50 +16,47 @@ e2d::ActionBase::~ActionBase()
|
|||
{
|
||||
}
|
||||
|
||||
bool e2d::ActionBase::isRunning()
|
||||
{
|
||||
return m_bRunning;
|
||||
}
|
||||
|
||||
bool e2d::ActionBase::_isDone()
|
||||
{
|
||||
return m_bEnding;
|
||||
return _bEnding;
|
||||
}
|
||||
|
||||
void e2d::ActionBase::startWithTarget(Node* target)
|
||||
void e2d::ActionBase::_startWithTarget(Node* target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_pTarget = target;
|
||||
this->reset();
|
||||
}
|
||||
_pTarget = target;
|
||||
_bRunning = true;
|
||||
this->reset();
|
||||
}
|
||||
|
||||
bool e2d::ActionBase::isRunning()
|
||||
{
|
||||
return _bRunning;
|
||||
}
|
||||
|
||||
void e2d::ActionBase::resume()
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_fLast = Time::getTotalTime();
|
||||
_bRunning = true;
|
||||
_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::ActionBase::pause()
|
||||
{
|
||||
m_bRunning = false;
|
||||
_bRunning = false;
|
||||
}
|
||||
|
||||
void e2d::ActionBase::stop()
|
||||
{
|
||||
m_bEnding = true;
|
||||
_bEnding = true;
|
||||
}
|
||||
|
||||
e2d::String e2d::ActionBase::getName() const
|
||||
{
|
||||
return m_sName;
|
||||
return _sName;
|
||||
}
|
||||
|
||||
void e2d::ActionBase::setName(const String& name)
|
||||
{
|
||||
m_sName = name;
|
||||
_sName = name;
|
||||
}
|
||||
|
||||
e2d::ActionBase * e2d::ActionBase::reverse() const
|
||||
|
|
@ -70,7 +67,7 @@ e2d::ActionBase * e2d::ActionBase::reverse() const
|
|||
|
||||
e2d::Node * e2d::ActionBase::getTarget()
|
||||
{
|
||||
return m_pTarget;
|
||||
return _pTarget;
|
||||
}
|
||||
|
||||
void e2d::ActionBase::destroy()
|
||||
|
|
@ -80,14 +77,14 @@ void e2d::ActionBase::destroy()
|
|||
|
||||
void e2d::ActionBase::_init()
|
||||
{
|
||||
m_bInit = true;
|
||||
_bInit = true;
|
||||
// ¼Ç¼µ±Ç°Ê±¼ä
|
||||
m_fLast = Time::getTotalTime();
|
||||
_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::ActionBase::_update()
|
||||
{
|
||||
if (!m_bInit)
|
||||
if (!_bInit)
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
|
@ -95,12 +92,12 @@ void e2d::ActionBase::_update()
|
|||
|
||||
void e2d::ActionBase::reset()
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bEnding = false;
|
||||
m_fLast = Time::getTotalTime();
|
||||
_bInit = false;
|
||||
_bEnding = false;
|
||||
_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::ActionBase::_resetTime()
|
||||
{
|
||||
m_fLast = Time::getTotalTime();
|
||||
_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
e2d::ActionDelay::ActionDelay(double duration)
|
||||
{
|
||||
m_fDelayTime = max(duration, 0);
|
||||
_fDelayTime = max(duration, 0);
|
||||
}
|
||||
|
||||
e2d::ActionDelay * e2d::ActionDelay::clone() const
|
||||
{
|
||||
return new ActionDelay(m_fDelayTime);
|
||||
return new ActionDelay(_fDelayTime);
|
||||
}
|
||||
|
||||
void e2d::ActionDelay::_init()
|
||||
|
|
@ -19,7 +19,7 @@ void e2d::ActionDelay::_update()
|
|||
{
|
||||
ActionBase::_update();
|
||||
// 判断时间间隔是否足够
|
||||
if ((Time::getTotalTime() - m_fLast) >= m_fDelayTime)
|
||||
if ((Time::getTotalTime() - _fLast) >= _fDelayTime)
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include "..\e2daction.h"
|
||||
|
||||
e2d::ActionFunc::ActionFunc(const Function& func) :
|
||||
m_Callback(func)
|
||||
_Callback(func)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ActionFunc * e2d::ActionFunc::clone() const
|
||||
{
|
||||
return new ActionFunc(m_Callback);
|
||||
return new ActionFunc(_Callback);
|
||||
}
|
||||
|
||||
void e2d::ActionFunc::_init()
|
||||
|
|
@ -17,6 +17,6 @@ void e2d::ActionFunc::_init()
|
|||
|
||||
void e2d::ActionFunc::_update()
|
||||
{
|
||||
m_Callback();
|
||||
_Callback();
|
||||
this->stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "..\e2daction.h"
|
||||
|
||||
e2d::ActionGradual::ActionGradual(double duration)
|
||||
: m_fRateOfProgress(0)
|
||||
: _fRateOfProgress(0)
|
||||
{
|
||||
m_fDuration = max(duration, 0);
|
||||
_fDuration = max(duration, 0);
|
||||
}
|
||||
|
||||
void e2d::ActionGradual::_init()
|
||||
|
|
@ -15,16 +15,16 @@ void e2d::ActionGradual::_update()
|
|||
{
|
||||
ActionBase::_update();
|
||||
// 判断时间间隔是否足够
|
||||
if (m_fDuration == 0)
|
||||
if (_fDuration == 0)
|
||||
{
|
||||
m_fRateOfProgress = 1;
|
||||
_fRateOfProgress = 1;
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
// 计算动画进度
|
||||
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
_fRateOfProgress = min((Time::getTotalTime() - _fLast) / _fDuration, 1);
|
||||
// 判断动作是否结束
|
||||
if (m_fRateOfProgress >= 1)
|
||||
if (_fRateOfProgress >= 1)
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
#include "..\e2dmanager.h"
|
||||
|
||||
e2d::ActionLoop::ActionLoop(ActionBase * action, int times /* = -1 */)
|
||||
: m_pAction(action)
|
||||
, m_nTimes(0)
|
||||
, m_nTotalTimes(times)
|
||||
: _pAction(action)
|
||||
, _nTimes(0)
|
||||
, _nTotalTimes(times)
|
||||
{
|
||||
ASSERT(m_pAction, "ActionLoop NULL pointer exception!");
|
||||
m_pAction->retain();
|
||||
ASSERT(_pAction, "ActionLoop NULL pointer exception!");
|
||||
_pAction->retain();
|
||||
}
|
||||
|
||||
e2d::ActionLoop::~ActionLoop()
|
||||
|
|
@ -16,34 +16,34 @@ e2d::ActionLoop::~ActionLoop()
|
|||
|
||||
e2d::ActionLoop * e2d::ActionLoop::clone() const
|
||||
{
|
||||
return new ActionLoop(m_pAction->clone());
|
||||
return new ActionLoop(_pAction->clone());
|
||||
}
|
||||
|
||||
void e2d::ActionLoop::_init()
|
||||
{
|
||||
ActionBase::_init();
|
||||
m_pAction->m_pTarget = m_pTarget;
|
||||
m_pAction->_init();
|
||||
_pAction->_pTarget = _pTarget;
|
||||
_pAction->_init();
|
||||
}
|
||||
|
||||
void e2d::ActionLoop::_update()
|
||||
{
|
||||
ActionBase::_update();
|
||||
|
||||
if (m_nTimes == m_nTotalTimes)
|
||||
if (_nTimes == _nTotalTimes)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
m_pAction->_update();
|
||||
_pAction->_update();
|
||||
|
||||
if (m_pAction->_isDone())
|
||||
if (_pAction->_isDone())
|
||||
{
|
||||
m_nTimes++;
|
||||
_nTimes++;
|
||||
|
||||
ActionBase::reset();
|
||||
m_pAction->reset();
|
||||
_pAction->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,17 +51,17 @@ void e2d::ActionLoop::reset()
|
|||
{
|
||||
ActionBase::reset();
|
||||
|
||||
m_pAction->reset();
|
||||
m_nTimes = 0;
|
||||
_pAction->reset();
|
||||
_nTimes = 0;
|
||||
}
|
||||
|
||||
void e2d::ActionLoop::destroy()
|
||||
{
|
||||
ActionBase::destroy();
|
||||
SafeRelease(&m_pAction);
|
||||
SafeRelease(&_pAction);
|
||||
}
|
||||
|
||||
void e2d::ActionLoop::_resetTime()
|
||||
{
|
||||
m_pAction->_resetTime();
|
||||
_pAction->_resetTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_MoveVec = vector;
|
||||
_MoveVec = vector;
|
||||
}
|
||||
|
||||
void e2d::ActionMoveBy::_init()
|
||||
{
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
if (_pTarget)
|
||||
{
|
||||
m_BeginPos = m_pTarget->getPos();
|
||||
_BeginPos = _pTarget->getPos();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,22 +20,22 @@ void e2d::ActionMoveBy::_update()
|
|||
{
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
if (_pTarget == nullptr)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// ÒÆ¶¯½Úµã
|
||||
m_pTarget->setPos(m_BeginPos + m_MoveVec * m_fRateOfProgress);
|
||||
_pTarget->setPos(_BeginPos + _MoveVec * _fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const
|
||||
{
|
||||
return new ActionMoveBy(m_fDuration, m_MoveVec);
|
||||
return new ActionMoveBy(_fDuration, _MoveVec);
|
||||
}
|
||||
|
||||
e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const
|
||||
{
|
||||
return new ActionMoveBy(m_fDuration, -m_MoveVec);
|
||||
return new ActionMoveBy(_fDuration, -_MoveVec);
|
||||
}
|
||||
|
|
@ -3,16 +3,16 @@
|
|||
e2d::ActionMoveTo::ActionMoveTo(double duration, Point pos) :
|
||||
ActionMoveBy(duration, Vector())
|
||||
{
|
||||
m_EndPos = pos;
|
||||
_EndPos = pos;
|
||||
}
|
||||
|
||||
e2d::ActionMoveTo * e2d::ActionMoveTo::clone() const
|
||||
{
|
||||
return new ActionMoveTo(m_fDuration, m_EndPos);
|
||||
return new ActionMoveTo(_fDuration, _EndPos);
|
||||
}
|
||||
|
||||
void e2d::ActionMoveTo::_init()
|
||||
{
|
||||
ActionMoveBy::_init();
|
||||
m_MoveVec = m_EndPos - m_BeginPos;
|
||||
_MoveVec = _EndPos - _BeginPos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
e2d::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_nVariation = opacity;
|
||||
_nVariation = opacity;
|
||||
}
|
||||
|
||||
void e2d::ActionOpacityBy::_init()
|
||||
{
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
if (_pTarget)
|
||||
{
|
||||
m_nBeginVal = m_pTarget->getOpacity();
|
||||
_nBeginVal = _pTarget->getOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,21 +20,21 @@ void e2d::ActionOpacityBy::_update()
|
|||
{
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
if (_pTarget == nullptr)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
// 设置节点透明度
|
||||
m_pTarget->setOpacity(m_nBeginVal + m_nVariation * m_fRateOfProgress);
|
||||
_pTarget->setOpacity(_nBeginVal + _nVariation * _fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const
|
||||
{
|
||||
return new ActionOpacityBy(m_fDuration, m_nVariation);
|
||||
return new ActionOpacityBy(_fDuration, _nVariation);
|
||||
}
|
||||
|
||||
e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const
|
||||
{
|
||||
return new ActionOpacityBy(m_fDuration, -m_nVariation);
|
||||
return new ActionOpacityBy(_fDuration, -_nVariation);
|
||||
}
|
||||
|
|
@ -4,16 +4,16 @@
|
|||
e2d::ActionOpacityTo::ActionOpacityTo(double duration, double opacity) :
|
||||
ActionOpacityBy(duration, 0)
|
||||
{
|
||||
m_nEndVal = opacity;
|
||||
_nEndVal = opacity;
|
||||
}
|
||||
|
||||
e2d::ActionOpacityTo * e2d::ActionOpacityTo::clone() const
|
||||
{
|
||||
return new ActionOpacityTo(m_fDuration, m_nEndVal);
|
||||
return new ActionOpacityTo(_fDuration, _nEndVal);
|
||||
}
|
||||
|
||||
void e2d::ActionOpacityTo::_init()
|
||||
{
|
||||
ActionOpacityBy::_init();
|
||||
m_nVariation = m_nEndVal - m_nBeginVal;
|
||||
_nVariation = _nEndVal - _nBeginVal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_nVariation = rotation;
|
||||
_nVariation = rotation;
|
||||
}
|
||||
|
||||
void e2d::ActionRotateBy::_init()
|
||||
{
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
if (_pTarget)
|
||||
{
|
||||
m_nBeginVal = m_pTarget->getRotation();
|
||||
_nBeginVal = _pTarget->getRotation();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,22 +20,22 @@ void e2d::ActionRotateBy::_update()
|
|||
{
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
if (_pTarget == nullptr)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ðýת½Úµã
|
||||
m_pTarget->setRotation(m_nBeginVal + m_nVariation * m_fRateOfProgress);
|
||||
_pTarget->setRotation(_nBeginVal + _nVariation * _fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const
|
||||
{
|
||||
return new ActionRotateBy(m_fDuration, m_nVariation);
|
||||
return new ActionRotateBy(_fDuration, _nVariation);
|
||||
}
|
||||
|
||||
e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const
|
||||
{
|
||||
return new ActionRotateBy(m_fDuration, -m_nVariation);
|
||||
return new ActionRotateBy(_fDuration, -_nVariation);
|
||||
}
|
||||
|
|
@ -4,16 +4,16 @@
|
|||
e2d::ActionRotateTo::ActionRotateTo(double duration, double rotation) :
|
||||
ActionRotateBy(duration, 0)
|
||||
{
|
||||
m_nEndVal = rotation;
|
||||
_nEndVal = rotation;
|
||||
}
|
||||
|
||||
e2d::ActionRotateTo * e2d::ActionRotateTo::clone() const
|
||||
{
|
||||
return new ActionRotateTo(m_fDuration, m_nEndVal);
|
||||
return new ActionRotateTo(_fDuration, _nEndVal);
|
||||
}
|
||||
|
||||
void e2d::ActionRotateTo::_init()
|
||||
{
|
||||
ActionRotateBy::_init();
|
||||
m_nVariation = m_nEndVal - m_nBeginVal;
|
||||
_nVariation = _nEndVal - _nBeginVal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,24 +4,24 @@
|
|||
e2d::ActionScaleBy::ActionScaleBy(double duration, double scale)
|
||||
: ActionGradual(duration)
|
||||
{
|
||||
m_nVariationX = scale;
|
||||
m_nVariationY = scale;
|
||||
_nVariationX = scale;
|
||||
_nVariationY = scale;
|
||||
}
|
||||
|
||||
e2d::ActionScaleBy::ActionScaleBy(double duration, double scaleX, double scaleY)
|
||||
: ActionGradual(duration)
|
||||
{
|
||||
m_nVariationX = scaleX;
|
||||
m_nVariationY = scaleY;
|
||||
_nVariationX = scaleX;
|
||||
_nVariationY = scaleY;
|
||||
}
|
||||
|
||||
void e2d::ActionScaleBy::_init()
|
||||
{
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
if (_pTarget)
|
||||
{
|
||||
m_nBeginScaleX = m_pTarget->getScaleX();
|
||||
m_nBeginScaleY = m_pTarget->getScaleY();
|
||||
_nBeginScaleX = _pTarget->getScaleX();
|
||||
_nBeginScaleY = _pTarget->getScaleY();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,24 +29,24 @@ void e2d::ActionScaleBy::_update()
|
|||
{
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
if (_pTarget == nullptr)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ëõ·Å½Úµã
|
||||
m_pTarget->setScale(
|
||||
m_nBeginScaleX + m_nVariationX * m_fRateOfProgress,
|
||||
m_nBeginScaleY + m_nVariationY * m_fRateOfProgress);
|
||||
_pTarget->setScale(
|
||||
_nBeginScaleX + _nVariationX * _fRateOfProgress,
|
||||
_nBeginScaleY + _nVariationY * _fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::ActionScaleBy * e2d::ActionScaleBy::clone() const
|
||||
{
|
||||
return new ActionScaleBy(m_fDuration, m_nVariationX, m_nVariationY);
|
||||
return new ActionScaleBy(_fDuration, _nVariationX, _nVariationY);
|
||||
}
|
||||
|
||||
e2d::ActionScaleBy * e2d::ActionScaleBy::reverse() const
|
||||
{
|
||||
return new ActionScaleBy(m_fDuration, -m_nVariationX, -m_nVariationY);
|
||||
return new ActionScaleBy(_fDuration, -_nVariationX, -_nVariationY);
|
||||
}
|
||||
|
|
@ -3,25 +3,25 @@
|
|||
e2d::ActionScaleTo::ActionScaleTo(double duration, double scale)
|
||||
: ActionScaleBy(duration, 0, 0)
|
||||
{
|
||||
m_nEndScaleX = scale;
|
||||
m_nEndScaleY = scale;
|
||||
_nEndScaleX = scale;
|
||||
_nEndScaleY = scale;
|
||||
}
|
||||
|
||||
e2d::ActionScaleTo::ActionScaleTo(double duration, double scaleX, double scaleY)
|
||||
: ActionScaleBy(duration, 0, 0)
|
||||
{
|
||||
m_nEndScaleX = scaleX;
|
||||
m_nEndScaleY = scaleY;
|
||||
_nEndScaleX = scaleX;
|
||||
_nEndScaleY = scaleY;
|
||||
}
|
||||
|
||||
e2d::ActionScaleTo * e2d::ActionScaleTo::clone() const
|
||||
{
|
||||
return new ActionScaleTo(m_fDuration, m_nEndScaleX, m_nEndScaleY);
|
||||
return new ActionScaleTo(_fDuration, _nEndScaleX, _nEndScaleY);
|
||||
}
|
||||
|
||||
void e2d::ActionScaleTo::_init()
|
||||
{
|
||||
ActionScaleBy::_init();
|
||||
m_nVariationX = m_nEndScaleX - m_nBeginScaleX;
|
||||
m_nVariationY = m_nEndScaleY - m_nBeginScaleY;
|
||||
_nVariationX = _nEndScaleX - _nBeginScaleX;
|
||||
_nVariationY = _nEndScaleY - _nBeginScaleY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#include "..\e2daction.h"
|
||||
|
||||
e2d::ActionSequence::ActionSequence()
|
||||
: m_nActionIndex(0)
|
||||
: _nActionIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HIGHER_THAN_VS2012
|
||||
e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions)
|
||||
: m_nActionIndex(0)
|
||||
: _nActionIndex(0)
|
||||
{
|
||||
this->add(vActions);
|
||||
}
|
||||
#else
|
||||
e2d::ActionSequence::ActionSequence(int number, ActionBase * action1, ...) :
|
||||
m_nActionIndex(0)
|
||||
_nActionIndex(0)
|
||||
{
|
||||
ActionBase ** ppAction = &action1;
|
||||
|
||||
|
|
@ -35,21 +35,21 @@ void e2d::ActionSequence::_init()
|
|||
{
|
||||
ActionBase::_init();
|
||||
// 将所有动作与目标绑定
|
||||
if (m_pTarget)
|
||||
if (_pTarget)
|
||||
{
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
action->m_pTarget = m_pTarget;
|
||||
action->_pTarget = _pTarget;
|
||||
}
|
||||
}
|
||||
// 初始化第一个动作
|
||||
m_vActions[0]->_init();
|
||||
_vActions[0]->_init();
|
||||
}
|
||||
|
||||
void e2d::ActionSequence::destroy()
|
||||
{
|
||||
ActionBase::destroy();
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
SafeRelease(&action);
|
||||
}
|
||||
|
|
@ -59,19 +59,19 @@ void e2d::ActionSequence::_update()
|
|||
{
|
||||
ActionBase::_update();
|
||||
|
||||
auto &action = m_vActions[m_nActionIndex];
|
||||
auto &action = _vActions[_nActionIndex];
|
||||
action->_update();
|
||||
|
||||
if (action->_isDone())
|
||||
{
|
||||
m_nActionIndex++;
|
||||
if (m_nActionIndex == m_vActions.size())
|
||||
_nActionIndex++;
|
||||
if (_nActionIndex == _vActions.size())
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vActions[m_nActionIndex]->_init();
|
||||
_vActions[_nActionIndex]->_init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -79,16 +79,16 @@ void e2d::ActionSequence::_update()
|
|||
void e2d::ActionSequence::reset()
|
||||
{
|
||||
ActionBase::reset();
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
action->reset();
|
||||
}
|
||||
m_nActionIndex = 0;
|
||||
_nActionIndex = 0;
|
||||
}
|
||||
|
||||
void e2d::ActionSequence::_resetTime()
|
||||
{
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
action->_resetTime();
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ void e2d::ActionSequence::add(ActionBase * action)
|
|||
{
|
||||
if (action)
|
||||
{
|
||||
m_vActions.push_back(action);
|
||||
_vActions.push_back(action);
|
||||
action->retain();
|
||||
}
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ void e2d::ActionSequence::add(int number, ActionBase * action, ...)
|
|||
e2d::ActionSequence * e2d::ActionSequence::clone() const
|
||||
{
|
||||
auto a = new ActionSequence();
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
a->add(action->clone());
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ e2d::ActionSequence * e2d::ActionSequence::clone() const
|
|||
e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const
|
||||
{
|
||||
auto a = new ActionSequence();
|
||||
for (auto action : m_vActions)
|
||||
for (auto action : _vActions)
|
||||
{
|
||||
if (actionReverse)
|
||||
{
|
||||
|
|
@ -151,6 +151,6 @@ e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const
|
|||
}
|
||||
}
|
||||
// 将动作顺序逆序排列
|
||||
a->m_vActions.reserve(m_vActions.size());
|
||||
a->_vActions.reserve(_vActions.size());
|
||||
return a;
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
#include "..\e2daction.h"
|
||||
|
||||
e2d::ActionTwo::ActionTwo(ActionBase * pActionFirst, ActionBase * pActionSecond, bool bAtSameTime/* = false*/)
|
||||
: m_pFirstAction(pActionFirst)
|
||||
, m_pSecondAction(pActionSecond)
|
||||
, m_bAtSameTime(bAtSameTime)
|
||||
: _pFirstAction(pActionFirst)
|
||||
, _pSecondAction(pActionSecond)
|
||||
, _bAtSameTime(bAtSameTime)
|
||||
{
|
||||
ASSERT(m_pFirstAction && m_pSecondAction, "ActionTwo NULL pointer exception!");
|
||||
m_pFirstAction->retain();
|
||||
m_pSecondAction->retain();
|
||||
ASSERT(_pFirstAction && _pSecondAction, "ActionTwo NULL pointer exception!");
|
||||
_pFirstAction->retain();
|
||||
_pSecondAction->retain();
|
||||
}
|
||||
|
||||
e2d::ActionTwo::~ActionTwo()
|
||||
|
|
@ -16,58 +16,58 @@ e2d::ActionTwo::~ActionTwo()
|
|||
|
||||
e2d::ActionTwo * e2d::ActionTwo::clone() const
|
||||
{
|
||||
return new ActionTwo(m_pFirstAction->clone(), m_pSecondAction->clone());
|
||||
return new ActionTwo(_pFirstAction->clone(), _pSecondAction->clone());
|
||||
}
|
||||
|
||||
e2d::ActionTwo * e2d::ActionTwo::reverse(bool actionReverse) const
|
||||
{
|
||||
if (actionReverse)
|
||||
{
|
||||
return new ActionTwo(m_pSecondAction->reverse(), m_pFirstAction->reverse());
|
||||
return new ActionTwo(_pSecondAction->reverse(), _pFirstAction->reverse());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ActionTwo(m_pSecondAction->clone(), m_pFirstAction->clone());
|
||||
return new ActionTwo(_pSecondAction->clone(), _pFirstAction->clone());
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ActionTwo::_init()
|
||||
{
|
||||
ActionBase::_init();
|
||||
m_pFirstAction->m_pTarget = m_pTarget;
|
||||
m_pSecondAction->m_pTarget = m_pTarget;
|
||||
_pFirstAction->_pTarget = _pTarget;
|
||||
_pSecondAction->_pTarget = _pTarget;
|
||||
|
||||
m_pFirstAction->_init();
|
||||
if (m_bAtSameTime) m_pSecondAction->_init();
|
||||
_pFirstAction->_init();
|
||||
if (_bAtSameTime) _pSecondAction->_init();
|
||||
}
|
||||
|
||||
void e2d::ActionTwo::_update()
|
||||
{
|
||||
ActionBase::_update();
|
||||
|
||||
if (!m_pFirstAction->_isDone())
|
||||
if (!_pFirstAction->_isDone())
|
||||
{
|
||||
m_pFirstAction->_update();
|
||||
_pFirstAction->_update();
|
||||
|
||||
if (!m_bAtSameTime && m_pFirstAction->_isDone())
|
||||
if (!_bAtSameTime && _pFirstAction->_isDone())
|
||||
{
|
||||
m_pSecondAction->_init();
|
||||
_pSecondAction->_init();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bAtSameTime)
|
||||
if (_bAtSameTime)
|
||||
{
|
||||
if (!m_pSecondAction->_isDone())
|
||||
if (!_pSecondAction->_isDone())
|
||||
{
|
||||
m_pSecondAction->_update();
|
||||
_pSecondAction->_update();
|
||||
}
|
||||
}
|
||||
else if (m_pFirstAction->_isDone())
|
||||
else if (_pFirstAction->_isDone())
|
||||
{
|
||||
m_pSecondAction->_update();
|
||||
_pSecondAction->_update();
|
||||
}
|
||||
|
||||
if (m_pFirstAction->_isDone() && m_pSecondAction->_isDone())
|
||||
if (_pFirstAction->_isDone() && _pSecondAction->_isDone())
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
|
|
@ -77,19 +77,19 @@ void e2d::ActionTwo::reset()
|
|||
{
|
||||
ActionBase::reset();
|
||||
|
||||
m_pFirstAction->reset();
|
||||
m_pSecondAction->reset();
|
||||
_pFirstAction->reset();
|
||||
_pSecondAction->reset();
|
||||
}
|
||||
|
||||
void e2d::ActionTwo::destroy()
|
||||
{
|
||||
ActionBase::destroy();
|
||||
SafeRelease(&m_pFirstAction);
|
||||
SafeRelease(&m_pSecondAction);
|
||||
SafeRelease(&_pFirstAction);
|
||||
SafeRelease(&_pSecondAction);
|
||||
}
|
||||
|
||||
void e2d::ActionTwo::_resetTime()
|
||||
{
|
||||
m_pFirstAction->_resetTime();
|
||||
m_pSecondAction->_resetTime();
|
||||
_pFirstAction->_resetTime();
|
||||
_pSecondAction->_resetTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
#include "..\e2daction.h"
|
||||
|
||||
e2d::Animation::Animation()
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(1)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(1)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Animation::Animation(double interval)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(interval)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(interval)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HIGHER_THAN_VS2012
|
||||
|
||||
e2d::Animation::Animation(const std::initializer_list<Image*>& vImages)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(1)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(1)
|
||||
{
|
||||
this->add(vImages);
|
||||
}
|
||||
|
||||
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(interval)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(interval)
|
||||
{
|
||||
this->add(vImages);
|
||||
}
|
||||
|
|
@ -31,8 +31,8 @@ e2d::Animation::Animation(double interval, const std::initializer_list<Image*>&
|
|||
#else
|
||||
|
||||
e2d::Animation::Animation(int number, Image * frame, ...)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(1)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(1)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
|
|
@ -46,8 +46,8 @@ e2d::Animation::Animation(int number, Image * frame, ...)
|
|||
}
|
||||
|
||||
e2d::Animation::Animation(double interval, int number, Image * frame, ...)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(interval)
|
||||
: _nFrameIndex(0)
|
||||
, _fInterval(interval)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ e2d::Animation::~Animation()
|
|||
|
||||
void e2d::Animation::setInterval(double interval)
|
||||
{
|
||||
m_fInterval = max(interval, 0);
|
||||
_fInterval = max(interval, 0);
|
||||
}
|
||||
|
||||
void e2d::Animation::_init()
|
||||
|
|
@ -80,22 +80,22 @@ void e2d::Animation::_update()
|
|||
{
|
||||
ActionBase::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
if (_pTarget == nullptr)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断时间间隔是否足够
|
||||
while ((Time::getTotalTime() - m_fLast) >= m_fInterval)
|
||||
while ((Time::getTotalTime() - _fLast) >= _fInterval)
|
||||
{
|
||||
// 重新记录时间
|
||||
m_fLast += m_fInterval;
|
||||
_fLast += _fInterval;
|
||||
// 加载关键帧
|
||||
static_cast<Sprite*>(m_pTarget)->open(m_vFrames[m_nFrameIndex]);
|
||||
m_nFrameIndex++;
|
||||
static_cast<Sprite*>(_pTarget)->open(_vFrames[_nFrameIndex]);
|
||||
_nFrameIndex++;
|
||||
// 判断动作是否结束
|
||||
if (m_nFrameIndex == m_vFrames.size())
|
||||
if (_nFrameIndex == _vFrames.size())
|
||||
{
|
||||
this->stop();
|
||||
break;
|
||||
|
|
@ -106,13 +106,13 @@ void e2d::Animation::_update()
|
|||
void e2d::Animation::reset()
|
||||
{
|
||||
ActionBase::reset();
|
||||
m_nFrameIndex = 0;
|
||||
_nFrameIndex = 0;
|
||||
}
|
||||
|
||||
void e2d::Animation::destroy()
|
||||
{
|
||||
ActionBase::destroy();
|
||||
for (auto frame : m_vFrames)
|
||||
for (auto frame : _vFrames)
|
||||
{
|
||||
SafeRelease(&frame);
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ void e2d::Animation::add(Image * frame)
|
|||
{
|
||||
if (frame)
|
||||
{
|
||||
m_vFrames.push_back(frame);
|
||||
_vFrames.push_back(frame);
|
||||
frame->retain();
|
||||
}
|
||||
}
|
||||
|
|
@ -152,8 +152,8 @@ void e2d::Animation::add(int number, Image * frame, ...)
|
|||
|
||||
e2d::Animation * e2d::Animation::clone() const
|
||||
{
|
||||
auto a = new Animation(m_fInterval);
|
||||
for (auto frame : m_vFrames)
|
||||
auto a = new Animation(_fInterval);
|
||||
for (auto frame : _vFrames)
|
||||
{
|
||||
a->add(frame);
|
||||
}
|
||||
|
|
@ -163,6 +163,6 @@ e2d::Animation * e2d::Animation::clone() const
|
|||
e2d::Animation * e2d::Animation::reverse() const
|
||||
{
|
||||
auto a = this->clone();
|
||||
a->m_vFrames.reserve(m_vFrames.size());
|
||||
a->_vFrames.reserve(_vFrames.size());
|
||||
return a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,10 +126,10 @@ int e2d::Game::start(bool autoRelease/* true */)
|
|||
Time::__updateLast(); // 刷新时间信息
|
||||
}
|
||||
Renderer::__render(); // 渲染游戏画面
|
||||
ObjectManager::__update(); // 刷新内存池
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectManager::__update(); // 刷新内存池
|
||||
Time::__sleep(); // 挂起线程
|
||||
}
|
||||
}
|
||||
|
|
@ -204,9 +204,9 @@ void e2d::Game::destroy()
|
|||
bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle)
|
||||
{
|
||||
// 创建进程互斥体
|
||||
HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sMutexName);
|
||||
HANDLE _hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sMutexName);
|
||||
|
||||
if (m_hMutex == nullptr)
|
||||
if (_hMutex == nullptr)
|
||||
{
|
||||
WARN_IF(true, "CreateMutex Failed!");
|
||||
return true;
|
||||
|
|
@ -216,7 +216,7 @@ bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle
|
|||
if (::GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
// 关闭进程互斥体
|
||||
::CloseHandle(m_hMutex);
|
||||
::CloseHandle(_hMutex);
|
||||
// 打开指定窗口
|
||||
if (!sWindowTitle.isEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,73 +3,73 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::Collider::Collider()
|
||||
: m_bIsVisiable(true)
|
||||
, m_nColor(Color::RED, 0.7f)
|
||||
, m_pParentNode(nullptr)
|
||||
, m_pTransformedGeometry(nullptr)
|
||||
, m_bEnable(true)
|
||||
, m_bAutoResize(true)
|
||||
: _bIsVisiable(true)
|
||||
, _nColor(Color::RED, 0.7f)
|
||||
, _pParentNode(nullptr)
|
||||
, _pTransformedGeometry(nullptr)
|
||||
, _bEnable(true)
|
||||
, _bAutoResize(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Collider::~Collider()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTransformedGeometry);
|
||||
SafeReleaseInterface(&_pTransformedGeometry);
|
||||
}
|
||||
|
||||
e2d::Node * e2d::Collider::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
return _pParentNode;
|
||||
}
|
||||
|
||||
e2d::Color e2d::Collider::getColor() const
|
||||
{
|
||||
return m_nColor;
|
||||
return _nColor;
|
||||
}
|
||||
|
||||
void e2d::Collider::setEnable(bool enable)
|
||||
{
|
||||
m_bEnable = enable;
|
||||
_bEnable = enable;
|
||||
}
|
||||
|
||||
void e2d::Collider::setVisiable(bool bVisiable)
|
||||
{
|
||||
m_bIsVisiable = bVisiable;
|
||||
_bIsVisiable = bVisiable;
|
||||
}
|
||||
|
||||
void e2d::Collider::setColor(Color color)
|
||||
{
|
||||
m_nColor = color;
|
||||
_nColor = color;
|
||||
}
|
||||
|
||||
void e2d::Collider::setAutoResize(bool enable)
|
||||
{
|
||||
m_bAutoResize = enable;
|
||||
_bAutoResize = enable;
|
||||
}
|
||||
|
||||
void e2d::Collider::_render()
|
||||
{
|
||||
if (m_pTransformedGeometry && m_bEnable)
|
||||
if (_pTransformedGeometry && _bEnable)
|
||||
{
|
||||
// 获取纯色画刷
|
||||
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush();
|
||||
// 设置画刷颜色和透明度
|
||||
pBrush->SetColor(m_nColor.toColorF());
|
||||
pBrush->SetColor(_nColor.toColorF());
|
||||
// 绘制几何碰撞体
|
||||
Renderer::getRenderTarget()->DrawGeometry(m_pTransformedGeometry, pBrush);
|
||||
Renderer::getRenderTarget()->DrawGeometry(_pTransformedGeometry, pBrush);
|
||||
}
|
||||
}
|
||||
|
||||
e2d::Relation e2d::Collider::getRelationWith(Collider * pCollider) const
|
||||
{
|
||||
if (m_pTransformedGeometry && pCollider->m_pTransformedGeometry)
|
||||
if (_pTransformedGeometry && pCollider->_pTransformedGeometry)
|
||||
{
|
||||
if (m_bEnable && pCollider->m_bEnable)
|
||||
if (_bEnable && pCollider->_bEnable)
|
||||
{
|
||||
D2D1_GEOMETRY_RELATION relation;
|
||||
|
||||
m_pTransformedGeometry->CompareWithGeometry(
|
||||
pCollider->m_pTransformedGeometry,
|
||||
_pTransformedGeometry->CompareWithGeometry(
|
||||
pCollider->_pTransformedGeometry,
|
||||
D2D1::Matrix3x2F::Identity(),
|
||||
&relation
|
||||
);
|
||||
|
|
@ -82,21 +82,21 @@ e2d::Relation e2d::Collider::getRelationWith(Collider * pCollider) const
|
|||
|
||||
void e2d::Collider::_transform()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
if (_pParentNode && _bEnable)
|
||||
{
|
||||
if (m_bAutoResize)
|
||||
if (_bAutoResize)
|
||||
{
|
||||
this->_resize();
|
||||
}
|
||||
|
||||
// 释放原碰撞体
|
||||
SafeReleaseInterface(&m_pTransformedGeometry);
|
||||
SafeReleaseInterface(&_pTransformedGeometry);
|
||||
|
||||
// 根据父节点转换几何图形
|
||||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
getD2dGeometry(),
|
||||
m_pParentNode->m_MatriFinal,
|
||||
&m_pTransformedGeometry
|
||||
_pParentNode->_MatriFinal,
|
||||
&_pTransformedGeometry
|
||||
);
|
||||
|
||||
ColliderManager::__updateCollider(this);
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::ColliderCircle::ColliderCircle()
|
||||
: m_pD2dCircle(nullptr)
|
||||
: _pD2dCircle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ColliderCircle::ColliderCircle(Point center, double radius)
|
||||
: m_pD2dCircle(nullptr)
|
||||
: _pD2dCircle(nullptr)
|
||||
{
|
||||
this->setCircle(center, radius);
|
||||
}
|
||||
|
||||
e2d::ColliderCircle::ColliderCircle(Node * node)
|
||||
: m_pD2dCircle(nullptr)
|
||||
: _pD2dCircle(nullptr)
|
||||
{
|
||||
double minSide = min(node->getRealWidth(), node->getRealHeight());
|
||||
this->setCircle(
|
||||
|
|
@ -27,12 +27,12 @@ e2d::ColliderCircle::ColliderCircle(Node * node)
|
|||
|
||||
e2d::ColliderCircle::~ColliderCircle()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
SafeReleaseInterface(&_pD2dCircle);
|
||||
}
|
||||
|
||||
void e2d::ColliderCircle::setCircle(Point center, double radius)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
SafeReleaseInterface(&_pD2dCircle);
|
||||
|
||||
Renderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
|
|
@ -41,19 +41,19 @@ void e2d::ColliderCircle::setCircle(Point center, double radius)
|
|||
static_cast<float>(center.y)),
|
||||
static_cast<float>(radius),
|
||||
static_cast<float>(radius)),
|
||||
&m_pD2dCircle
|
||||
&_pD2dCircle
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::ColliderCircle::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
if (_pParentNode && _bEnable)
|
||||
{
|
||||
double minSide = min(m_pParentNode->getRealWidth(), m_pParentNode->getRealHeight());
|
||||
double minSide = min(_pParentNode->getRealWidth(), _pParentNode->getRealHeight());
|
||||
this->setCircle(
|
||||
Point(
|
||||
m_pParentNode->getRealWidth() / 2,
|
||||
m_pParentNode->getRealHeight() / 2
|
||||
_pParentNode->getRealWidth() / 2,
|
||||
_pParentNode->getRealHeight() / 2
|
||||
),
|
||||
minSide / 2
|
||||
);
|
||||
|
|
@ -62,5 +62,5 @@ void e2d::ColliderCircle::_resize()
|
|||
|
||||
ID2D1EllipseGeometry * e2d::ColliderCircle::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dCircle;
|
||||
return _pD2dCircle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::ColliderEllipse::ColliderEllipse()
|
||||
: m_pD2dEllipse(nullptr)
|
||||
: _pD2dEllipse(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ColliderEllipse::ColliderEllipse(Point center, double radiusX, double radiusY)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
: _pD2dEllipse(nullptr)
|
||||
{
|
||||
this->setEllipse(center, radiusX, radiusY);
|
||||
}
|
||||
|
||||
e2d::ColliderEllipse::ColliderEllipse(Node * node)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
: _pD2dEllipse(nullptr)
|
||||
{
|
||||
this->setEllipse(
|
||||
Point(
|
||||
|
|
@ -27,12 +27,12 @@ e2d::ColliderEllipse::ColliderEllipse(Node * node)
|
|||
|
||||
e2d::ColliderEllipse::~ColliderEllipse()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
SafeReleaseInterface(&_pD2dEllipse);
|
||||
}
|
||||
|
||||
void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiusY)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
SafeReleaseInterface(&_pD2dEllipse);
|
||||
|
||||
Renderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
|
|
@ -41,26 +41,26 @@ void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiu
|
|||
static_cast<float>(center.y)),
|
||||
static_cast<float>(radiusX),
|
||||
static_cast<float>(radiusY)),
|
||||
&m_pD2dEllipse
|
||||
&_pD2dEllipse
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::ColliderEllipse::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
if (_pParentNode && _bEnable)
|
||||
{
|
||||
this->setEllipse(
|
||||
Point(
|
||||
m_pParentNode->getWidth() / 2,
|
||||
m_pParentNode->getHeight() / 2
|
||||
_pParentNode->getWidth() / 2,
|
||||
_pParentNode->getHeight() / 2
|
||||
),
|
||||
m_pParentNode->getWidth() / 2,
|
||||
m_pParentNode->getHeight() / 2
|
||||
_pParentNode->getWidth() / 2,
|
||||
_pParentNode->getHeight() / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ID2D1EllipseGeometry * e2d::ColliderEllipse::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dEllipse;
|
||||
return _pD2dEllipse;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,30 +2,30 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::ColliderRect::ColliderRect()
|
||||
: m_pD2dRectangle(nullptr)
|
||||
: _pD2dRectangle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ColliderRect::ColliderRect(double x, double y, double width, double height)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
: _pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
e2d::ColliderRect::ColliderRect(Node * node)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
: _pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(0, 0, node->getRealWidth(), node->getRealHeight());
|
||||
}
|
||||
|
||||
e2d::ColliderRect::~ColliderRect()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
SafeReleaseInterface(&_pD2dRectangle);
|
||||
}
|
||||
|
||||
void e2d::ColliderRect::setRect(double left, double top, double right, double bottom)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
SafeReleaseInterface(&_pD2dRectangle);
|
||||
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(
|
||||
|
|
@ -33,19 +33,19 @@ void e2d::ColliderRect::setRect(double left, double top, double right, double bo
|
|||
static_cast<float>(top),
|
||||
static_cast<float>(right),
|
||||
static_cast<float>(bottom)),
|
||||
&m_pD2dRectangle
|
||||
&_pD2dRectangle
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::ColliderRect::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
if (_pParentNode && _bEnable)
|
||||
{
|
||||
this->setRect( 0, 0, m_pParentNode->getRealWidth(), m_pParentNode->getRealHeight());
|
||||
this->setRect( 0, 0, _pParentNode->getRealWidth(), _pParentNode->getRealHeight());
|
||||
}
|
||||
}
|
||||
|
||||
ID2D1RectangleGeometry * e2d::ColliderRect::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dRectangle;
|
||||
return _pD2dRectangle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
#include "..\e2dcommon.h"
|
||||
|
||||
e2d::Function::Function()
|
||||
: m_func(nullptr)
|
||||
: _func(nullptr)
|
||||
{}
|
||||
|
||||
e2d::Function::Function(std::nullptr_t)
|
||||
: m_func(nullptr)
|
||||
: _func(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Function::Function(std::function<void()> func)
|
||||
: m_func(func)
|
||||
: _func(func)
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::Function::operator()(void) const
|
||||
{
|
||||
if (m_func)
|
||||
if (_func)
|
||||
{
|
||||
m_func();
|
||||
_func();
|
||||
}
|
||||
}
|
||||
|
||||
e2d::Function::operator bool() const
|
||||
{
|
||||
return static_cast<bool>(m_func);
|
||||
return static_cast<bool>(_func);
|
||||
}
|
||||
|
|
@ -6,35 +6,35 @@ static std::map<int, ID2D1Bitmap*> s_mBitmapsFromResource;
|
|||
|
||||
|
||||
e2d::Image::Image()
|
||||
: m_pBitmap(nullptr)
|
||||
, m_fSourceCropX(0)
|
||||
, m_fSourceCropY(0)
|
||||
, m_fSourceCropWidth(0)
|
||||
, m_fSourceCropHeight(0)
|
||||
: _pBitmap(nullptr)
|
||||
, _fSourceCropX(0)
|
||||
, _fSourceCropY(0)
|
||||
, _fSourceCropWidth(0)
|
||||
, _fSourceCropHeight(0)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Image::Image(const String& filePath)
|
||||
: m_pBitmap(nullptr)
|
||||
: _pBitmap(nullptr)
|
||||
{
|
||||
this->open(filePath);
|
||||
}
|
||||
|
||||
e2d::Image::Image(int resNameId, const String& resType)
|
||||
: m_pBitmap(nullptr)
|
||||
: _pBitmap(nullptr)
|
||||
{
|
||||
this->open(resNameId, resType);
|
||||
}
|
||||
|
||||
e2d::Image::Image(const String& filePath, double cropX, double cropY, double cropWidth, double cropHeight)
|
||||
: m_pBitmap(nullptr)
|
||||
: _pBitmap(nullptr)
|
||||
{
|
||||
this->open(filePath);
|
||||
this->crop(cropX, cropY, cropWidth, cropHeight);
|
||||
}
|
||||
|
||||
e2d::Image::Image(int resNameId, const String& resType, double cropX, double cropY, double cropWidth, double cropHeight)
|
||||
: m_pBitmap(nullptr)
|
||||
: _pBitmap(nullptr)
|
||||
{
|
||||
this->open(resNameId, resType);
|
||||
this->crop(cropX, cropY, cropWidth, cropHeight);
|
||||
|
|
@ -57,10 +57,10 @@ bool e2d::Image::open(const String& filePath)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode());
|
||||
m_fSourceCropX = m_fSourceCropY = 0;
|
||||
m_fSourceCropWidth = m_pBitmap->GetSize().width;
|
||||
m_fSourceCropHeight = m_pBitmap->GetSize().height;
|
||||
_pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode());
|
||||
_fSourceCropX = _fSourceCropY = 0;
|
||||
_fSourceCropWidth = _pBitmap->GetSize().width;
|
||||
_fSourceCropHeight = _pBitmap->GetSize().height;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -72,44 +72,44 @@ bool e2d::Image::open(int resNameId, const String& resType)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_pBitmap = s_mBitmapsFromResource.at(resNameId);
|
||||
m_fSourceCropX = m_fSourceCropY = 0;
|
||||
m_fSourceCropWidth = m_pBitmap->GetSize().width;
|
||||
m_fSourceCropHeight = m_pBitmap->GetSize().height;
|
||||
_pBitmap = s_mBitmapsFromResource.at(resNameId);
|
||||
_fSourceCropX = _fSourceCropY = 0;
|
||||
_fSourceCropWidth = _pBitmap->GetSize().width;
|
||||
_fSourceCropHeight = _pBitmap->GetSize().height;
|
||||
return true;
|
||||
}
|
||||
|
||||
void e2d::Image::crop(double x, double y, double width, double height)
|
||||
{
|
||||
if (m_pBitmap)
|
||||
if (_pBitmap)
|
||||
{
|
||||
m_fSourceCropX = min(max(x, 0), this->getSourceWidth());
|
||||
m_fSourceCropY = min(max(y, 0), this->getSourceHeight());
|
||||
m_fSourceCropWidth = min(max(width, 0), this->getSourceWidth() - m_fSourceCropX);
|
||||
m_fSourceCropHeight = min(max(height, 0), this->getSourceHeight() - m_fSourceCropY);
|
||||
_fSourceCropX = min(max(x, 0), this->getSourceWidth());
|
||||
_fSourceCropY = min(max(y, 0), this->getSourceHeight());
|
||||
_fSourceCropWidth = min(max(width, 0), this->getSourceWidth() - _fSourceCropX);
|
||||
_fSourceCropHeight = min(max(height, 0), this->getSourceHeight() - _fSourceCropY);
|
||||
}
|
||||
}
|
||||
|
||||
double e2d::Image::getWidth() const
|
||||
{
|
||||
return m_fSourceCropWidth;
|
||||
return _fSourceCropWidth;
|
||||
}
|
||||
|
||||
double e2d::Image::getHeight() const
|
||||
{
|
||||
return m_fSourceCropHeight;
|
||||
return _fSourceCropHeight;
|
||||
}
|
||||
|
||||
e2d::Size e2d::Image::getSize() const
|
||||
{
|
||||
return Size(m_fSourceCropWidth, m_fSourceCropHeight);
|
||||
return Size(_fSourceCropWidth, _fSourceCropHeight);
|
||||
}
|
||||
|
||||
double e2d::Image::getSourceWidth() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
if (_pBitmap)
|
||||
{
|
||||
return m_pBitmap->GetSize().width;
|
||||
return _pBitmap->GetSize().width;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -119,9 +119,9 @@ double e2d::Image::getSourceWidth() const
|
|||
|
||||
double e2d::Image::getSourceHeight() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
if (_pBitmap)
|
||||
{
|
||||
return m_pBitmap->GetSize().height;
|
||||
return _pBitmap->GetSize().height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -131,7 +131,7 @@ double e2d::Image::getSourceHeight() const
|
|||
|
||||
e2d::Size e2d::Image::getSourceSize() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
if (_pBitmap)
|
||||
{
|
||||
return Size(getSourceWidth(), getSourceHeight());
|
||||
}
|
||||
|
|
@ -143,17 +143,17 @@ e2d::Size e2d::Image::getSourceSize() const
|
|||
|
||||
double e2d::Image::getCropX() const
|
||||
{
|
||||
return m_fSourceCropX;
|
||||
return _fSourceCropX;
|
||||
}
|
||||
|
||||
double e2d::Image::getCropY() const
|
||||
{
|
||||
return m_fSourceCropY;
|
||||
return _fSourceCropY;
|
||||
}
|
||||
|
||||
e2d::Point e2d::Image::getCropPos() const
|
||||
{
|
||||
return Point(m_fSourceCropX, m_fSourceCropY);
|
||||
return Point(_fSourceCropX, _fSourceCropY);
|
||||
}
|
||||
|
||||
bool e2d::Image::preload(const String& fileName)
|
||||
|
|
@ -376,5 +376,5 @@ void e2d::Image::clearCache()
|
|||
|
||||
ID2D1Bitmap * e2d::Image::getBitmap()
|
||||
{
|
||||
return m_pBitmap;
|
||||
return _pBitmap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "..\e2dmanager.h"
|
||||
|
||||
e2d::Object::Object()
|
||||
: m_nRefCount(0)
|
||||
: _nRefCount(0)
|
||||
{
|
||||
ObjectManager::__add(this);
|
||||
}
|
||||
|
|
@ -14,18 +14,18 @@ e2d::Object::~Object()
|
|||
// 引用计数加一
|
||||
void e2d::Object::retain()
|
||||
{
|
||||
m_nRefCount++;
|
||||
_nRefCount++;
|
||||
}
|
||||
|
||||
// 引用计数减一
|
||||
void e2d::Object::release()
|
||||
{
|
||||
m_nRefCount--;
|
||||
_nRefCount--;
|
||||
// 通知对象管理池刷新
|
||||
ObjectManager::flush();
|
||||
}
|
||||
|
||||
int e2d::Object::getRefCount() const
|
||||
{
|
||||
return m_nRefCount;
|
||||
return _nRefCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
#include "..\e2dmanager.h"
|
||||
|
||||
e2d::Scene::Scene()
|
||||
: m_bWillSave(true)
|
||||
, m_bAutoUpdate(true)
|
||||
, m_bSortNeeded(false)
|
||||
, m_bColliderVisiable(false)
|
||||
, m_pRoot(new Node())
|
||||
: _bWillSave(true)
|
||||
, _bAutoUpdate(true)
|
||||
, _bSortNeeded(false)
|
||||
, _bColliderVisiable(false)
|
||||
, _pRoot(new Node())
|
||||
{
|
||||
m_pRoot->retain();
|
||||
m_pRoot->_setParentScene(this);
|
||||
_pRoot->retain();
|
||||
_pRoot->_setParentScene(this);
|
||||
}
|
||||
|
||||
e2d::Scene::~Scene()
|
||||
|
|
@ -19,36 +19,36 @@ e2d::Scene::~Scene()
|
|||
|
||||
void e2d::Scene::_render()
|
||||
{
|
||||
m_pRoot->_render();
|
||||
_pRoot->_render();
|
||||
|
||||
if (m_bColliderVisiable)
|
||||
if (_bColliderVisiable)
|
||||
{
|
||||
// 恢复矩阵转换
|
||||
Renderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
// 绘制所有几何图形
|
||||
m_pRoot->_drawCollider();
|
||||
_pRoot->_drawCollider();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Scene::_update()
|
||||
{
|
||||
// 执行 onUpdate 函数
|
||||
if (m_bAutoUpdate)
|
||||
if (_bAutoUpdate)
|
||||
{
|
||||
this->onUpdate();
|
||||
}
|
||||
// 更新根节点
|
||||
m_pRoot->_update();
|
||||
_pRoot->_update();
|
||||
}
|
||||
|
||||
void e2d::Scene::setAutoUpdate(bool bAutoUpdate)
|
||||
{
|
||||
m_bAutoUpdate = bAutoUpdate;
|
||||
_bAutoUpdate = bAutoUpdate;
|
||||
}
|
||||
|
||||
void e2d::Scene::add(Node * child, int order /* = 0 */)
|
||||
{
|
||||
m_pRoot->addChild(child, order);
|
||||
_pRoot->addChild(child, order);
|
||||
}
|
||||
|
||||
#ifdef HIGHER_THAN_VS2012
|
||||
|
|
@ -63,35 +63,35 @@ void e2d::Scene::add(const std::initializer_list<Node*>& vNodes, int order)
|
|||
|
||||
bool e2d::Scene::remove(Node * child)
|
||||
{
|
||||
return m_pRoot->removeChild(child);
|
||||
return _pRoot->removeChild(child);
|
||||
}
|
||||
|
||||
std::vector<e2d::Node*> e2d::Scene::get(const String& name) const
|
||||
{
|
||||
return m_pRoot->getChildren(name);
|
||||
return _pRoot->getChildren(name);
|
||||
}
|
||||
|
||||
e2d::Node * e2d::Scene::getOne(const String& name) const
|
||||
{
|
||||
return m_pRoot->getChild(name);
|
||||
return _pRoot->getChild(name);
|
||||
}
|
||||
|
||||
std::vector<e2d::Node*> e2d::Scene::getAll() const
|
||||
{
|
||||
return m_pRoot->getAllChildren();
|
||||
return _pRoot->getAllChildren();
|
||||
}
|
||||
|
||||
e2d::Node * e2d::Scene::getRoot() const
|
||||
{
|
||||
return m_pRoot;
|
||||
return _pRoot;
|
||||
}
|
||||
|
||||
void e2d::Scene::showCollider(bool visiable)
|
||||
{
|
||||
m_bColliderVisiable = visiable;
|
||||
_bColliderVisiable = visiable;
|
||||
}
|
||||
|
||||
void e2d::Scene::destroy()
|
||||
{
|
||||
SafeRelease(&m_pRoot);
|
||||
SafeRelease(&_pRoot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,72 +5,72 @@
|
|||
|
||||
|
||||
e2d::String::String()
|
||||
: m_str(L"")
|
||||
: _str(L"")
|
||||
{
|
||||
}
|
||||
|
||||
e2d::String::String(const wchar_t *str)
|
||||
: m_str(str)
|
||||
: _str(str)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::String::String(const char *cstr)
|
||||
: m_str(static_cast<wchar_t*>(_bstr_t(cstr)))
|
||||
: _str(static_cast<wchar_t*>(_bstr_t(cstr)))
|
||||
{
|
||||
}
|
||||
|
||||
e2d::String::String(e2d::String && str)
|
||||
{
|
||||
m_str = std::move(str.m_str);
|
||||
_str = std::move(str._str);
|
||||
}
|
||||
|
||||
e2d::String::String(const e2d::String &str)
|
||||
: m_str(str.m_str)
|
||||
: _str(str._str)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::String::~String()
|
||||
{
|
||||
m_str.clear();
|
||||
_str.clear();
|
||||
}
|
||||
|
||||
e2d::String &e2d::String::operator=(const wchar_t *str)
|
||||
{
|
||||
m_str = str;
|
||||
_str = str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator=(const char *cstr)
|
||||
{
|
||||
m_str = static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
_str = static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(int value)
|
||||
{
|
||||
String tmp;
|
||||
tmp.m_str = std::to_wstring(value);
|
||||
tmp._str = std::to_wstring(value);
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(unsigned int value)
|
||||
{
|
||||
String tmp;
|
||||
tmp.m_str = std::to_wstring(value);
|
||||
tmp._str = std::to_wstring(value);
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(float value)
|
||||
{
|
||||
String tmp;
|
||||
tmp.m_str = std::to_wstring(value);
|
||||
tmp._str = std::to_wstring(value);
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(double value)
|
||||
{
|
||||
String tmp;
|
||||
tmp.m_str = std::to_wstring(value);
|
||||
tmp._str = std::to_wstring(value);
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
|
|
@ -81,11 +81,11 @@ e2d::String e2d::String::format(const char * format, ...)
|
|||
va_list marker = NULL;
|
||||
va_start(marker, format);
|
||||
|
||||
size_t num_of_chars = _vscprintf(format, marker);
|
||||
size_t nu_of_chars = _vscprintf(format, marker);
|
||||
|
||||
if (num_of_chars > tmp.capacity())
|
||||
if (nu_of_chars > tmp.capacity())
|
||||
{
|
||||
tmp.resize(num_of_chars + 1);
|
||||
tmp.resize(nu_of_chars + 1);
|
||||
}
|
||||
|
||||
vsprintf_s(const_cast<LPSTR>(tmp.data()), tmp.capacity(), format, marker);
|
||||
|
|
@ -103,11 +103,11 @@ e2d::String e2d::String::format(const wchar_t * format, ...)
|
|||
va_list marker = NULL;
|
||||
va_start(marker, format);
|
||||
|
||||
size_t num_of_chars = _vscwprintf(format, marker);
|
||||
size_t nu_of_chars = _vscwprintf(format, marker);
|
||||
|
||||
if (num_of_chars > tmp.capacity())
|
||||
if (nu_of_chars > tmp.capacity())
|
||||
{
|
||||
tmp.resize(num_of_chars + 1);
|
||||
tmp.resize(nu_of_chars + 1);
|
||||
}
|
||||
|
||||
vswprintf_s(const_cast<LPWSTR>(tmp.data()), tmp.capacity(), format, marker);
|
||||
|
|
@ -120,12 +120,12 @@ e2d::String e2d::String::format(const wchar_t * format, ...)
|
|||
|
||||
void e2d::String::swap(String & str1, String & str2)
|
||||
{
|
||||
str1.m_str.swap(str2.m_str);
|
||||
str1._str.swap(str2._str);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator=(const String &str)
|
||||
{
|
||||
m_str = str.m_str;
|
||||
_str = str._str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ bool e2d::String::operator==(const wchar_t *str)
|
|||
{
|
||||
if (str)
|
||||
{
|
||||
return (m_str.compare(str) == 0);
|
||||
return (_str.compare(str) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -146,7 +146,7 @@ bool e2d::String::operator==(const char *str)
|
|||
if (str)
|
||||
{
|
||||
String temp(str);
|
||||
return (m_str == temp.m_str);
|
||||
return (_str == temp._str);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -156,14 +156,14 @@ bool e2d::String::operator==(const char *str)
|
|||
|
||||
bool e2d::String::operator ==(const e2d::String &str)
|
||||
{
|
||||
return m_str == str.m_str;
|
||||
return _str == str._str;
|
||||
}
|
||||
|
||||
bool e2d::String::operator!=(const wchar_t *str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
return (m_str.compare(str) != 0);
|
||||
return (_str.compare(str) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -176,7 +176,7 @@ bool e2d::String::operator!=(const char *str)
|
|||
if (str)
|
||||
{
|
||||
String temp(str);
|
||||
return (m_str != temp.m_str);
|
||||
return (_str != temp._str);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -186,114 +186,114 @@ bool e2d::String::operator!=(const char *str)
|
|||
|
||||
bool e2d::String::operator!=(const e2d::String &str)
|
||||
{
|
||||
return m_str != str.m_str;
|
||||
return _str != str._str;
|
||||
}
|
||||
|
||||
wchar_t &e2d::String::operator[](int index)
|
||||
{
|
||||
return m_str[static_cast<size_t>(index)];
|
||||
return _str[static_cast<size_t>(index)];
|
||||
}
|
||||
|
||||
e2d::String e2d::String::operator+(const wchar_t *str)
|
||||
{
|
||||
String temp;
|
||||
temp.m_str = m_str + str;
|
||||
temp._str = _str + str;
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::operator+(const char *str)
|
||||
{
|
||||
String temp;
|
||||
temp.m_str = m_str + static_cast<wchar_t*>(_bstr_t(str));
|
||||
temp._str = _str + static_cast<wchar_t*>(_bstr_t(str));
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::operator+(const e2d::String &str)
|
||||
{
|
||||
String temp;
|
||||
temp.m_str = m_str + str.m_str;
|
||||
temp._str = _str + str._str;
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2)
|
||||
{
|
||||
String temp;
|
||||
temp.m_str = str1 + str2.m_str;
|
||||
temp._str = str1 + str2._str;
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
e2d::String e2d::operator+(const char *str1, const String &str2)
|
||||
{
|
||||
String temp;
|
||||
temp.m_str = static_cast<wchar_t*>(_bstr_t(str1)) + str2.m_str;
|
||||
temp._str = static_cast<wchar_t*>(_bstr_t(str1)) + str2._str;
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator+=(const wchar_t *str)
|
||||
{
|
||||
m_str += str;
|
||||
_str += str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator+=(const char *str)
|
||||
{
|
||||
m_str += static_cast<wchar_t*>(_bstr_t(str));
|
||||
_str += static_cast<wchar_t*>(_bstr_t(str));
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator+=(const String &str)
|
||||
{
|
||||
m_str += str.m_str;
|
||||
_str += str._str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
bool e2d::String::operator>(const String &str) const
|
||||
{
|
||||
return m_str > str.m_str;
|
||||
return _str > str._str;
|
||||
}
|
||||
|
||||
bool e2d::String::operator>=(const String &str) const
|
||||
{
|
||||
return m_str >= str.m_str;
|
||||
return _str >= str._str;
|
||||
}
|
||||
|
||||
bool e2d::String::operator<(const String &str) const
|
||||
{
|
||||
return m_str < str.m_str;
|
||||
return _str < str._str;
|
||||
}
|
||||
|
||||
bool e2d::String::operator<=(const String &str) const
|
||||
{
|
||||
return m_str <= str.m_str;
|
||||
return _str <= str._str;
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(const String &str)
|
||||
{
|
||||
m_str += str.m_str;
|
||||
_str += str._str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(const wchar_t *str)
|
||||
{
|
||||
m_str += str;
|
||||
_str += str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(wchar_t *str)
|
||||
{
|
||||
m_str += str;
|
||||
_str += str;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(const char * cstr)
|
||||
{
|
||||
m_str += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
_str += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(char * cstr)
|
||||
{
|
||||
m_str += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
_str += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
|
@ -323,22 +323,22 @@ e2d::String & e2d::String::operator<<(double value)
|
|||
|
||||
e2d::String::operator const wchar_t*() const
|
||||
{
|
||||
return m_str.c_str();
|
||||
return _str.c_str();
|
||||
}
|
||||
|
||||
e2d::String::operator wchar_t*() const
|
||||
{
|
||||
return const_cast<wchar_t*>(m_str.c_str());
|
||||
return const_cast<wchar_t*>(_str.c_str());
|
||||
}
|
||||
|
||||
bool e2d::String::isEmpty() const
|
||||
{
|
||||
return m_str.empty();
|
||||
return _str.empty();
|
||||
}
|
||||
|
||||
int e2d::String::getLength() const
|
||||
{
|
||||
return static_cast<int>(m_str.size());
|
||||
return static_cast<int>(_str.size());
|
||||
}
|
||||
|
||||
unsigned int e2d::String::getHashCode() const
|
||||
|
|
@ -348,25 +348,25 @@ unsigned int e2d::String::getHashCode() const
|
|||
for (int i = 0; i < getLength(); i++)
|
||||
{
|
||||
hash *= 16777619;
|
||||
hash ^= (unsigned int)towupper(m_str[i]);
|
||||
hash ^= (unsigned int)towupper(_str[i]);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
std::wstring e2d::String::getWString() const
|
||||
{
|
||||
return m_str;
|
||||
return _str;
|
||||
}
|
||||
|
||||
std::string e2d::String::getCString() const
|
||||
{
|
||||
std::string str = static_cast<const char *>(_bstr_t(m_str.c_str()));
|
||||
std::string str = static_cast<const char *>(_bstr_t(_str.c_str()));
|
||||
return std::move(str);
|
||||
}
|
||||
|
||||
int e2d::String::compare(const String & str) const
|
||||
{
|
||||
return m_str.compare(str.m_str);
|
||||
return _str.compare(str._str);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::toUpper() const
|
||||
|
|
@ -395,7 +395,7 @@ int e2d::String::toInt() const
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
return std::stoi(m_str, 0, 10);
|
||||
return std::stoi(_str, 0, 10);
|
||||
}
|
||||
|
||||
double e2d::String::toDouble() const
|
||||
|
|
@ -404,7 +404,7 @@ double e2d::String::toDouble() const
|
|||
{
|
||||
return 0.0;
|
||||
}
|
||||
return std::stod(m_str, 0);
|
||||
return std::stod(_str, 0);
|
||||
}
|
||||
|
||||
bool e2d::String::toBool() const
|
||||
|
|
@ -414,7 +414,7 @@ bool e2d::String::toBool() const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_str.compare(L"0") == 0 || m_str.compare(L"false") == 0)
|
||||
if (_str.compare(L"0") == 0 || _str.compare(L"false") == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -434,37 +434,37 @@ e2d::String e2d::String::subtract(int offset, int count) const
|
|||
if (count < 0 || (offset + count) > length)
|
||||
count = length - offset;
|
||||
|
||||
tmp.m_str = m_str.substr(offset, count);
|
||||
tmp._str = _str.substr(offset, count);
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
void e2d::String::insert(const String & str, int pos)
|
||||
{
|
||||
m_str.insert(static_cast<size_t>(pos), str.m_str);
|
||||
_str.insert(static_cast<size_t>(pos), str._str);
|
||||
}
|
||||
|
||||
void e2d::String::replace(const String & from, const String & to)
|
||||
{
|
||||
if (from.m_str.empty())
|
||||
if (from._str.empty())
|
||||
return;
|
||||
|
||||
size_t start_pos = 0;
|
||||
while ((start_pos = m_str.find(from, start_pos)) != std::string::npos)
|
||||
while ((start_pos = _str.find(from, start_pos)) != std::string::npos)
|
||||
{
|
||||
m_str.replace(start_pos, from.m_str.length(), to);
|
||||
start_pos += to.m_str.length();
|
||||
_str.replace(start_pos, from._str.length(), to);
|
||||
start_pos += to._str.length();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::String::erase(int offset, int count)
|
||||
{
|
||||
m_str.erase(static_cast<size_t>(offset), static_cast<size_t>(count));
|
||||
_str.erase(static_cast<size_t>(offset), static_cast<size_t>(count));
|
||||
}
|
||||
|
||||
int e2d::String::find(const String & str, int offset) const
|
||||
{
|
||||
size_t index;
|
||||
if ((index = m_str.find(str.m_str, static_cast<size_t>(offset))) == std::wstring::npos)
|
||||
if ((index = _str.find(str._str, static_cast<size_t>(offset))) == std::wstring::npos)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -476,24 +476,24 @@ int e2d::String::find(const String & str, int offset) const
|
|||
|
||||
void e2d::String::clear()
|
||||
{
|
||||
m_str.clear();
|
||||
_str.clear();
|
||||
}
|
||||
|
||||
std::wostream & e2d::operator<<(std::wostream &cout, const String &str)
|
||||
{
|
||||
cout << str.m_str;
|
||||
cout << str._str;
|
||||
return cout;
|
||||
}
|
||||
|
||||
std::wistream & e2d::operator>>(std::wistream &cin, String &str)
|
||||
{
|
||||
cin >> str.m_str;
|
||||
cin >> str._str;
|
||||
return cin;
|
||||
}
|
||||
|
||||
std::ostream & e2d::operator<<(std::ostream &cout, const String &str)
|
||||
{
|
||||
std::string cstr = static_cast<char*>(_bstr_t(str.m_str.c_str()));
|
||||
std::string cstr = static_cast<char*>(_bstr_t(str._str.c_str()));
|
||||
cout << cstr;
|
||||
return cout;
|
||||
}
|
||||
|
|
@ -502,6 +502,6 @@ std::istream & e2d::operator>>(std::istream &cin, String &str)
|
|||
{
|
||||
std::string temp;
|
||||
cin >> temp;
|
||||
str.m_str = static_cast<wchar_t*>(_bstr_t(temp.c_str()));
|
||||
str._str = static_cast<wchar_t*>(_bstr_t(temp.c_str()));
|
||||
return cin;
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ void e2d::ActionManager::__update()
|
|||
{
|
||||
// ¶¯×÷ÒѾ½áÊø
|
||||
action->release();
|
||||
action->m_pTarget = nullptr;
|
||||
action->_pTarget = nullptr;
|
||||
s_vRunningActions.erase(s_vRunningActions.begin() + i);
|
||||
}
|
||||
else
|
||||
|
|
@ -33,52 +33,36 @@ void e2d::ActionManager::__update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__add(ActionBase * pAction)
|
||||
void e2d::ActionManager::__add(ActionBase * action)
|
||||
{
|
||||
if (pAction)
|
||||
if (action)
|
||||
{
|
||||
for (auto action : s_vActions)
|
||||
{
|
||||
if (action == pAction)
|
||||
{
|
||||
WARN_IF(true, "ActionManager::add Failed!The action is already added.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
s_vActions.push_back(pAction);
|
||||
s_vActions.push_back(action);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__remove(ActionBase * pAction)
|
||||
void e2d::ActionManager::__remove(ActionBase * action)
|
||||
{
|
||||
for (size_t i = 0; i < s_vActions.size(); i++)
|
||||
for (size_t i = 0; i < s_vActions.size();)
|
||||
{
|
||||
if (s_vActions[i] == pAction)
|
||||
if (s_vActions[i] == action)
|
||||
{
|
||||
s_vActions.erase(s_vActions.begin() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__startAction(ActionBase * pAction, Node * pTargetNode)
|
||||
void e2d::ActionManager::__resumeAllBindedWith(Node * target)
|
||||
{
|
||||
WARN_IF(pAction == nullptr, "ActionBase NULL pointer exception!");
|
||||
|
||||
if (pAction)
|
||||
{
|
||||
pAction->startWithTarget(pTargetNode);
|
||||
pAction->retain();
|
||||
s_vRunningActions.push_back(pAction);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__resumeAllBindedWith(Node * pTargetNode)
|
||||
{
|
||||
if (pTargetNode)
|
||||
if (target)
|
||||
{
|
||||
for (auto action : s_vRunningActions)
|
||||
{
|
||||
if (action->getTarget() == pTargetNode)
|
||||
if (action->getTarget() == target)
|
||||
{
|
||||
action->resume();
|
||||
}
|
||||
|
|
@ -86,13 +70,13 @@ void e2d::ActionManager::__resumeAllBindedWith(Node * pTargetNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__pauseAllBindedWith(Node * pTargetNode)
|
||||
void e2d::ActionManager::__pauseAllBindedWith(Node * target)
|
||||
{
|
||||
if (pTargetNode)
|
||||
if (target)
|
||||
{
|
||||
for (auto action : s_vRunningActions)
|
||||
{
|
||||
if (action->getTarget() == pTargetNode)
|
||||
if (action->getTarget() == target)
|
||||
{
|
||||
action->pause();
|
||||
}
|
||||
|
|
@ -100,13 +84,13 @@ void e2d::ActionManager::__pauseAllBindedWith(Node * pTargetNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode)
|
||||
void e2d::ActionManager::__stopAllBindedWith(Node * target)
|
||||
{
|
||||
if (pTargetNode)
|
||||
if (target)
|
||||
{
|
||||
for (auto action : s_vRunningActions)
|
||||
{
|
||||
if (action->getTarget() == pTargetNode)
|
||||
if (action->getTarget() == target)
|
||||
{
|
||||
action->stop();
|
||||
}
|
||||
|
|
@ -114,6 +98,20 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::start(ActionBase * action, Node * target, bool paused)
|
||||
{
|
||||
WARN_IF(action == nullptr, "ActionBase NULL pointer exception!");
|
||||
WARN_IF(target == nullptr, "Target node NULL pointer exception!");
|
||||
|
||||
if (action && target)
|
||||
{
|
||||
action->_startWithTarget(target);
|
||||
action->retain();
|
||||
action->_bRunning = !paused;
|
||||
s_vRunningActions.push_back(action);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::resume(const String& strActionName)
|
||||
{
|
||||
for (auto action : s_vRunningActions)
|
||||
|
|
@ -147,14 +145,14 @@ void e2d::ActionManager::stop(const String& strActionName)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionManager::__clearAllBindedWith(Node * pTargetNode)
|
||||
void e2d::ActionManager::__clearAllBindedWith(Node * target)
|
||||
{
|
||||
if (pTargetNode)
|
||||
if (target)
|
||||
{
|
||||
for (size_t i = 0; i < s_vRunningActions.size();)
|
||||
{
|
||||
auto a = s_vRunningActions[i];
|
||||
if (a->getTarget() == pTargetNode)
|
||||
if (a->getTarget() == target)
|
||||
{
|
||||
SafeRelease(&a);
|
||||
s_vRunningActions.erase(s_vRunningActions.begin() + i);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
|
|||
if (!s_bCollisionEnable)
|
||||
return;
|
||||
|
||||
Node* pActiveNode = pActiveCollider->m_pParentNode;
|
||||
Node* pActiveNode = pActiveCollider->_pParentNode;
|
||||
if (pActiveNode)
|
||||
{
|
||||
// 获取节点所在场景
|
||||
|
|
@ -96,7 +96,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
|
|||
continue;
|
||||
|
||||
// 获取被碰撞节点
|
||||
Node* pPassiveNode = pPassiveCollider->m_pParentNode;
|
||||
Node* pPassiveNode = pPassiveCollider->_pParentNode;
|
||||
// 判断两节点是否处于同一场景中
|
||||
if (pPassiveNode &&
|
||||
pPassiveNode->getParentScene() == pCurrentScene)
|
||||
|
|
@ -105,7 +105,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
|
|||
auto IsCollideWith = [](Node * active, Node * passive) -> bool
|
||||
{
|
||||
unsigned int hash = passive->getHashName();
|
||||
for (auto collider : active->m_vColliders)
|
||||
for (auto collider : active->_vColliders)
|
||||
if (collider == hash)
|
||||
return true;
|
||||
return false;
|
||||
|
|
@ -206,11 +206,11 @@ e2d::Node * e2d::ColliderManager::getPassiveNode()
|
|||
return s_pPassiveNode;
|
||||
}
|
||||
|
||||
e2d::Node* e2d::ColliderManager::isCausedBy(Node * pNode)
|
||||
e2d::Node* e2d::ColliderManager::isCausedBy(Node * node)
|
||||
{
|
||||
if (s_pActiveNode == pNode)
|
||||
if (s_pActiveNode == node)
|
||||
return s_pPassiveNode;
|
||||
if (s_pPassiveNode == pNode)
|
||||
if (s_pPassiveNode == node)
|
||||
return s_pActiveNode;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ void e2d::ColliderManager::__addCollider(Collider * pCollider)
|
|||
{
|
||||
if (pCollider)
|
||||
{
|
||||
if (pCollider->m_pParentNode)
|
||||
if (pCollider->_pParentNode)
|
||||
{
|
||||
WARN_IF(true, "ColliderManager::__add Failed! The shape is already added.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "..\e2dbase.h"
|
||||
|
||||
// ObjectManager 释放池的实现机制:
|
||||
// Object 类中的引用计数(m_nRefCount)在一定程度上保证了指针的使用安全
|
||||
// Object 类中的引用计数(_nRefCount)在一定程度上保证了指针的使用安全
|
||||
// 它记录了对象被使用的次数,当计数为 0 时,ObjectManager 会自动释放这个对象
|
||||
// 所有的 Object 对象都应在被使用时(例如 Text 添加到了场景中)
|
||||
// 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数
|
||||
|
|
@ -17,15 +17,12 @@ void e2d::ObjectManager::__update()
|
|||
if (!s_bNotifyed) return;
|
||||
|
||||
s_bNotifyed = false;
|
||||
// 循环遍历容器中的所有对象
|
||||
for (auto iter = s_vObjectPool.begin(); iter != s_vObjectPool.end();)
|
||||
{
|
||||
if ((*iter)->getRefCount() <= 0)
|
||||
{
|
||||
// 若对象的引用的计数小于等于 0, 释放该对象
|
||||
(*iter)->destroy();
|
||||
delete (*iter);
|
||||
// 从释放池中删除该对象
|
||||
iter = s_vObjectPool.erase(iter);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void e2d::SceneManager::enter(Scene * scene, TransitionBase * transition /* = nu
|
|||
|
||||
if (s_pCurrScene)
|
||||
{
|
||||
s_pCurrScene->m_bWillSave = saveCurrentScene;
|
||||
s_pCurrScene->_bWillSave = saveCurrentScene;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ void e2d::SceneManager::back(TransitionBase * transition /* = nullptr */)
|
|||
// 返回上一场景时,不保存当前场景
|
||||
if (s_pCurrScene)
|
||||
{
|
||||
s_pCurrScene->m_bWillSave = false;
|
||||
s_pCurrScene->_bWillSave = false;
|
||||
}
|
||||
|
||||
// 设置切换场景动画
|
||||
|
|
@ -120,7 +120,7 @@ void e2d::SceneManager::__update()
|
|||
s_pCurrScene->onExit();
|
||||
|
||||
// 若要保存当前场景,把它放入栈中
|
||||
if (s_pCurrScene->m_bWillSave)
|
||||
if (s_pCurrScene->_bWillSave)
|
||||
{
|
||||
s_SceneStack.push(s_pCurrScene);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,40 +5,40 @@
|
|||
|
||||
|
||||
e2d::Button::Button()
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
, m_pMouseover(nullptr)
|
||||
, m_pSelected(nullptr)
|
||||
, m_pDisabled(nullptr)
|
||||
: _Callback(nullptr)
|
||||
, _eBtnState(ButtonState::NORMAL)
|
||||
, _bEnable(true)
|
||||
, _bIsSelected(false)
|
||||
, _pNormal(nullptr)
|
||||
, _pMouseover(nullptr)
|
||||
, _pSelected(nullptr)
|
||||
, _pDisabled(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Button::Button(Node * normal, const Function& func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
, m_pMouseover(nullptr)
|
||||
, m_pSelected(nullptr)
|
||||
, m_pDisabled(nullptr)
|
||||
: _Callback(nullptr)
|
||||
, _eBtnState(ButtonState::NORMAL)
|
||||
, _bEnable(true)
|
||||
, _bIsSelected(false)
|
||||
, _pNormal(nullptr)
|
||||
, _pMouseover(nullptr)
|
||||
, _pSelected(nullptr)
|
||||
, _pDisabled(nullptr)
|
||||
{
|
||||
this->setNormal(normal);
|
||||
this->setClickFunc(func);
|
||||
}
|
||||
|
||||
e2d::Button::Button(Node * normal, Node * selected, const Function& func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
, m_pMouseover(nullptr)
|
||||
, m_pSelected(nullptr)
|
||||
, m_pDisabled(nullptr)
|
||||
: _Callback(nullptr)
|
||||
, _eBtnState(ButtonState::NORMAL)
|
||||
, _bEnable(true)
|
||||
, _bIsSelected(false)
|
||||
, _pNormal(nullptr)
|
||||
, _pMouseover(nullptr)
|
||||
, _pSelected(nullptr)
|
||||
, _pDisabled(nullptr)
|
||||
{
|
||||
this->setNormal(normal);
|
||||
this->setSelected(selected);
|
||||
|
|
@ -46,14 +46,14 @@ e2d::Button::Button(Node * normal, Node * selected, const Function& func)
|
|||
}
|
||||
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
, m_pMouseover(nullptr)
|
||||
, m_pSelected(nullptr)
|
||||
, m_pDisabled(nullptr)
|
||||
: _Callback(nullptr)
|
||||
, _eBtnState(ButtonState::NORMAL)
|
||||
, _bEnable(true)
|
||||
, _bIsSelected(false)
|
||||
, _pNormal(nullptr)
|
||||
, _pMouseover(nullptr)
|
||||
, _pSelected(nullptr)
|
||||
, _pDisabled(nullptr)
|
||||
{
|
||||
this->setNormal(normal);
|
||||
this->setMouseOver(mouseover);
|
||||
|
|
@ -62,14 +62,14 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Func
|
|||
}
|
||||
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
, m_pMouseover(nullptr)
|
||||
, m_pSelected(nullptr)
|
||||
, m_pDisabled(nullptr)
|
||||
: _Callback(nullptr)
|
||||
, _eBtnState(ButtonState::NORMAL)
|
||||
, _bEnable(true)
|
||||
, _bIsSelected(false)
|
||||
, _pNormal(nullptr)
|
||||
, _pMouseover(nullptr)
|
||||
, _pSelected(nullptr)
|
||||
, _pDisabled(nullptr)
|
||||
{
|
||||
this->setNormal(normal);
|
||||
this->setMouseOver(mouseover);
|
||||
|
|
@ -80,17 +80,17 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * dis
|
|||
|
||||
bool e2d::Button::isEnable() const
|
||||
{
|
||||
return m_bEnable;
|
||||
return _bEnable;
|
||||
}
|
||||
|
||||
void e2d::Button::setNormal(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormal)
|
||||
if (normal != _pNormal)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pNormal)
|
||||
if (_pNormal)
|
||||
{
|
||||
this->removeChild(m_pNormal);
|
||||
this->removeChild(_pNormal);
|
||||
}
|
||||
// 添加新的
|
||||
if (normal)
|
||||
|
|
@ -98,7 +98,7 @@ void e2d::Button::setNormal(Node * normal)
|
|||
this->addChild(normal);
|
||||
this->setSize(normal->getWidth(), normal->getHeight());
|
||||
}
|
||||
m_pNormal = normal;
|
||||
_pNormal = normal;
|
||||
|
||||
_updateVisiable();
|
||||
}
|
||||
|
|
@ -106,75 +106,75 @@ void e2d::Button::setNormal(Node * normal)
|
|||
|
||||
void e2d::Button::setMouseOver(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pNormal)
|
||||
if (mouseover != _pNormal)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pMouseover)
|
||||
if (_pMouseover)
|
||||
{
|
||||
this->removeChild(m_pMouseover);
|
||||
this->removeChild(_pMouseover);
|
||||
}
|
||||
// 添加新的
|
||||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
}
|
||||
m_pMouseover = mouseover;
|
||||
_pMouseover = mouseover;
|
||||
_updateVisiable();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::setSelected(Node * selected)
|
||||
{
|
||||
if (selected != m_pNormal)
|
||||
if (selected != _pNormal)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pSelected)
|
||||
if (_pSelected)
|
||||
{
|
||||
this->removeChild(m_pSelected);
|
||||
this->removeChild(_pSelected);
|
||||
}
|
||||
// 添加新的
|
||||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
}
|
||||
m_pSelected = selected;
|
||||
_pSelected = selected;
|
||||
_updateVisiable();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::setDisabled(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pNormal)
|
||||
if (disabled != _pNormal)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pDisabled)
|
||||
if (_pDisabled)
|
||||
{
|
||||
this->removeChild(m_pDisabled);
|
||||
this->removeChild(_pDisabled);
|
||||
}
|
||||
// 添加新的
|
||||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
}
|
||||
m_pDisabled = disabled;
|
||||
_pDisabled = disabled;
|
||||
_updateVisiable();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::setEnable(bool enable)
|
||||
{
|
||||
if (m_bEnable != enable)
|
||||
if (_bEnable != enable)
|
||||
{
|
||||
m_bEnable = enable;
|
||||
_bEnable = enable;
|
||||
_updateVisiable();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::setClickFunc(const Function& func)
|
||||
{
|
||||
WARN_IF(m_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");
|
||||
WARN_IF(_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");
|
||||
|
||||
m_Callback = func;
|
||||
_Callback = func;
|
||||
}
|
||||
|
||||
void e2d::Button::onFixedUpdate()
|
||||
|
|
@ -182,40 +182,40 @@ void e2d::Button::onFixedUpdate()
|
|||
if (SceneManager::isTransitioning())
|
||||
return;
|
||||
|
||||
if (m_bEnable && m_bVisiable && m_pNormal)
|
||||
if (_bEnable && _bVisiable && _pNormal)
|
||||
{
|
||||
if (Input::isMouseLButtonRelease())
|
||||
{
|
||||
// 鼠标左键抬起时,判断鼠标坐标是否在按钮内部
|
||||
if (m_bIsSelected &&
|
||||
m_pNormal->isPointIn(Input::getMousePos()))
|
||||
if (_bIsSelected &&
|
||||
_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_runCallback();
|
||||
}
|
||||
// 标记 m_bIsSelected 为 false
|
||||
m_bIsSelected = false;
|
||||
// 标记 _bIsSelected 为 false
|
||||
_bIsSelected = false;
|
||||
}
|
||||
|
||||
if (Input::isMouseLButtonPress())
|
||||
{
|
||||
if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
if (_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
// 鼠标左键按下,且位于按钮内时,标记 m_bIsSelected 为 true
|
||||
m_bIsSelected = true;
|
||||
// 鼠标左键按下,且位于按钮内时,标记 _bIsSelected 为 true
|
||||
_bIsSelected = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bIsSelected && Input::isMouseLButtonDown())
|
||||
if (_bIsSelected && Input::isMouseLButtonDown())
|
||||
{
|
||||
if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
if (_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(ButtonState::SELECTED);
|
||||
Window::setCursor(Cursor::HAND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
else if (_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(ButtonState::MOUSEOVER);
|
||||
Window::setCursor(Cursor::HAND);
|
||||
|
|
@ -225,7 +225,7 @@ void e2d::Button::onFixedUpdate()
|
|||
_setState(ButtonState::NORMAL);
|
||||
}
|
||||
|
||||
if (m_bVisiable && !m_bEnable && m_pNormal && m_pNormal->isPointIn(Input::getMousePos()))
|
||||
if (_bVisiable && !_bEnable && _pNormal && _pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
Window::setCursor(Cursor::NO);
|
||||
}
|
||||
|
|
@ -233,52 +233,52 @@ void e2d::Button::onFixedUpdate()
|
|||
|
||||
void e2d::Button::_setState(ButtonState state)
|
||||
{
|
||||
if (m_eBtnState != state)
|
||||
if (_eBtnState != state)
|
||||
{
|
||||
m_eBtnState = state;
|
||||
_eBtnState = state;
|
||||
_updateVisiable();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::_updateVisiable()
|
||||
{
|
||||
SAFE_SET(m_pNormal, setVisiable, false);
|
||||
SAFE_SET(m_pMouseover, setVisiable, false);
|
||||
SAFE_SET(m_pSelected, setVisiable, false);
|
||||
SAFE_SET(m_pDisabled, setVisiable, false);
|
||||
SAFE_SET(_pNormal, setVisiable, false);
|
||||
SAFE_SET(_pMouseover, setVisiable, false);
|
||||
SAFE_SET(_pSelected, setVisiable, false);
|
||||
SAFE_SET(_pDisabled, setVisiable, false);
|
||||
|
||||
if (m_bEnable)
|
||||
if (_bEnable)
|
||||
{
|
||||
if (m_eBtnState == ButtonState::SELECTED && m_pSelected)
|
||||
if (_eBtnState == ButtonState::SELECTED && _pSelected)
|
||||
{
|
||||
m_pSelected->setVisiable(true);
|
||||
_pSelected->setVisiable(true);
|
||||
}
|
||||
else if (m_eBtnState == ButtonState::MOUSEOVER && m_pMouseover)
|
||||
else if (_eBtnState == ButtonState::MOUSEOVER && _pMouseover)
|
||||
{
|
||||
m_pMouseover->setVisiable(true);
|
||||
_pMouseover->setVisiable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pNormal) m_pNormal->setVisiable(true);
|
||||
if (_pNormal) _pNormal->setVisiable(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pDisabled)
|
||||
if (_pDisabled)
|
||||
{
|
||||
m_pDisabled->setVisiable(true);
|
||||
_pDisabled->setVisiable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pNormal) m_pNormal->setVisiable(true);
|
||||
if (_pNormal) _pNormal->setVisiable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::_runCallback()
|
||||
{
|
||||
if (m_Callback)
|
||||
if (_Callback)
|
||||
{
|
||||
m_Callback();
|
||||
_Callback();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
e2d::ButtonToggle::ButtonToggle()
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
, m_pSelectedOn(nullptr)
|
||||
, m_pDisabledOn(nullptr)
|
||||
, m_pNormalOff(nullptr)
|
||||
, m_pMouseoverOff(nullptr)
|
||||
, m_pSelectedOff(nullptr)
|
||||
, m_pDisabledOff(nullptr)
|
||||
, _bState(true)
|
||||
, _pNormalOn(nullptr)
|
||||
, _pMouseoverOn(nullptr)
|
||||
, _pSelectedOn(nullptr)
|
||||
, _pDisabledOn(nullptr)
|
||||
, _pNormalOff(nullptr)
|
||||
, _pMouseoverOff(nullptr)
|
||||
, _pSelectedOff(nullptr)
|
||||
, _pDisabledOff(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, const Function& func)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
, m_pSelectedOn(nullptr)
|
||||
, m_pDisabledOn(nullptr)
|
||||
, m_pNormalOff(nullptr)
|
||||
, m_pMouseoverOff(nullptr)
|
||||
, m_pSelectedOff(nullptr)
|
||||
, m_pDisabledOff(nullptr)
|
||||
, _bState(true)
|
||||
, _pNormalOn(nullptr)
|
||||
, _pMouseoverOn(nullptr)
|
||||
, _pSelectedOn(nullptr)
|
||||
, _pDisabledOn(nullptr)
|
||||
, _pNormalOff(nullptr)
|
||||
, _pMouseoverOff(nullptr)
|
||||
, _pSelectedOff(nullptr)
|
||||
, _pDisabledOff(nullptr)
|
||||
{
|
||||
this->setNormal(toggleOnNormal);
|
||||
this->setNormalOff(toggleOffNormal);
|
||||
|
|
@ -33,15 +33,15 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, c
|
|||
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
, m_pSelectedOn(nullptr)
|
||||
, m_pDisabledOn(nullptr)
|
||||
, m_pNormalOff(nullptr)
|
||||
, m_pMouseoverOff(nullptr)
|
||||
, m_pSelectedOff(nullptr)
|
||||
, m_pDisabledOff(nullptr)
|
||||
, _bState(true)
|
||||
, _pNormalOn(nullptr)
|
||||
, _pMouseoverOn(nullptr)
|
||||
, _pSelectedOn(nullptr)
|
||||
, _pDisabledOn(nullptr)
|
||||
, _pNormalOff(nullptr)
|
||||
, _pMouseoverOff(nullptr)
|
||||
, _pSelectedOff(nullptr)
|
||||
, _pDisabledOff(nullptr)
|
||||
{
|
||||
this->setNormal(toggleOnNormal);
|
||||
this->setNormalOff(toggleOffNormal);
|
||||
|
|
@ -52,15 +52,15 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
|||
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
, m_pSelectedOn(nullptr)
|
||||
, m_pDisabledOn(nullptr)
|
||||
, m_pNormalOff(nullptr)
|
||||
, m_pMouseoverOff(nullptr)
|
||||
, m_pSelectedOff(nullptr)
|
||||
, m_pDisabledOff(nullptr)
|
||||
, _bState(true)
|
||||
, _pNormalOn(nullptr)
|
||||
, _pMouseoverOn(nullptr)
|
||||
, _pSelectedOn(nullptr)
|
||||
, _pDisabledOn(nullptr)
|
||||
, _pNormalOff(nullptr)
|
||||
, _pMouseoverOff(nullptr)
|
||||
, _pSelectedOff(nullptr)
|
||||
, _pDisabledOff(nullptr)
|
||||
{
|
||||
this->setNormal(toggleOnNormal);
|
||||
this->setNormalOff(toggleOffNormal);
|
||||
|
|
@ -73,15 +73,15 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
|||
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, const Function& func)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
, m_pSelectedOn(nullptr)
|
||||
, m_pDisabledOn(nullptr)
|
||||
, m_pNormalOff(nullptr)
|
||||
, m_pMouseoverOff(nullptr)
|
||||
, m_pSelectedOff(nullptr)
|
||||
, m_pDisabledOff(nullptr)
|
||||
, _bState(true)
|
||||
, _pNormalOn(nullptr)
|
||||
, _pMouseoverOn(nullptr)
|
||||
, _pSelectedOn(nullptr)
|
||||
, _pDisabledOn(nullptr)
|
||||
, _pNormalOff(nullptr)
|
||||
, _pMouseoverOff(nullptr)
|
||||
, _pSelectedOff(nullptr)
|
||||
, _pDisabledOff(nullptr)
|
||||
{
|
||||
this->setNormal(toggleOnNormal);
|
||||
this->setNormalOff(toggleOffNormal);
|
||||
|
|
@ -96,14 +96,14 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
|||
|
||||
bool e2d::ButtonToggle::getState() const
|
||||
{
|
||||
return m_bState;
|
||||
return _bState;
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::setState(bool bState)
|
||||
{
|
||||
if (m_bState != bState)
|
||||
if (_bState != bState)
|
||||
{
|
||||
m_bState = bState;
|
||||
_bState = bState;
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
}
|
||||
|
|
@ -111,12 +111,12 @@ void e2d::ButtonToggle::setState(bool bState)
|
|||
|
||||
void e2d::ButtonToggle::setNormal(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormalOn)
|
||||
if (normal != _pNormalOn)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pNormalOn)
|
||||
if (_pNormalOn)
|
||||
{
|
||||
this->removeChild(m_pNormalOn);
|
||||
this->removeChild(_pNormalOn);
|
||||
}
|
||||
// 添加新的
|
||||
if (normal)
|
||||
|
|
@ -124,7 +124,7 @@ void e2d::ButtonToggle::setNormal(Node * normal)
|
|||
this->addChild(normal);
|
||||
this->setSize(normal->getWidth(), normal->getHeight());
|
||||
}
|
||||
m_pNormalOn = normal;
|
||||
_pNormalOn = normal;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -133,19 +133,19 @@ void e2d::ButtonToggle::setNormal(Node * normal)
|
|||
|
||||
void e2d::ButtonToggle::setMouseOver(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pMouseoverOn)
|
||||
if (mouseover != _pMouseoverOn)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pMouseoverOn)
|
||||
if (_pMouseoverOn)
|
||||
{
|
||||
this->removeChild(m_pMouseoverOn);
|
||||
this->removeChild(_pMouseoverOn);
|
||||
}
|
||||
// 添加新的
|
||||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
}
|
||||
m_pMouseoverOn = mouseover;
|
||||
_pMouseoverOn = mouseover;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -154,19 +154,19 @@ void e2d::ButtonToggle::setMouseOver(Node * mouseover)
|
|||
|
||||
void e2d::ButtonToggle::setSelected(Node * selected)
|
||||
{
|
||||
if (selected != m_pSelectedOn)
|
||||
if (selected != _pSelectedOn)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pSelectedOn)
|
||||
if (_pSelectedOn)
|
||||
{
|
||||
this->removeChild(m_pSelectedOn);
|
||||
this->removeChild(_pSelectedOn);
|
||||
}
|
||||
// 添加新的
|
||||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
}
|
||||
m_pSelectedOn = selected;
|
||||
_pSelectedOn = selected;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -175,19 +175,19 @@ void e2d::ButtonToggle::setSelected(Node * selected)
|
|||
|
||||
void e2d::ButtonToggle::setDisabled(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pDisabledOn)
|
||||
if (disabled != _pDisabledOn)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pDisabledOn)
|
||||
if (_pDisabledOn)
|
||||
{
|
||||
this->removeChild(m_pDisabledOn);
|
||||
this->removeChild(_pDisabledOn);
|
||||
}
|
||||
// 添加新的
|
||||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
}
|
||||
m_pDisabledOn = disabled;
|
||||
_pDisabledOn = disabled;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -196,19 +196,19 @@ void e2d::ButtonToggle::setDisabled(Node * disabled)
|
|||
|
||||
void e2d::ButtonToggle::setNormalOff(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormalOff)
|
||||
if (normal != _pNormalOff)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pNormalOff)
|
||||
if (_pNormalOff)
|
||||
{
|
||||
this->removeChild(m_pNormalOff);
|
||||
this->removeChild(_pNormalOff);
|
||||
}
|
||||
// 添加新的
|
||||
if (normal)
|
||||
{
|
||||
this->addChild(normal);
|
||||
}
|
||||
m_pNormalOff = normal;
|
||||
_pNormalOff = normal;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -217,19 +217,19 @@ void e2d::ButtonToggle::setNormalOff(Node * normal)
|
|||
|
||||
void e2d::ButtonToggle::setMouseOverOff(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pMouseoverOff)
|
||||
if (mouseover != _pMouseoverOff)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pMouseoverOff)
|
||||
if (_pMouseoverOff)
|
||||
{
|
||||
this->removeChild(m_pMouseoverOff);
|
||||
this->removeChild(_pMouseoverOff);
|
||||
}
|
||||
// 添加新的
|
||||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
}
|
||||
m_pMouseoverOff = mouseover;
|
||||
_pMouseoverOff = mouseover;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -238,19 +238,19 @@ void e2d::ButtonToggle::setMouseOverOff(Node * mouseover)
|
|||
|
||||
void e2d::ButtonToggle::setSelectedOff(Node * selected)
|
||||
{
|
||||
if (selected != m_pSelectedOff)
|
||||
if (selected != _pSelectedOff)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pSelectedOff)
|
||||
if (_pSelectedOff)
|
||||
{
|
||||
this->removeChild(m_pSelectedOff);
|
||||
this->removeChild(_pSelectedOff);
|
||||
}
|
||||
// 添加新的
|
||||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
}
|
||||
m_pSelectedOff = selected;
|
||||
_pSelectedOff = selected;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -259,19 +259,19 @@ void e2d::ButtonToggle::setSelectedOff(Node * selected)
|
|||
|
||||
void e2d::ButtonToggle::setDisabledOff(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pDisabledOff)
|
||||
if (disabled != _pDisabledOff)
|
||||
{
|
||||
// 移除旧的
|
||||
if (m_pDisabledOff)
|
||||
if (_pDisabledOff)
|
||||
{
|
||||
this->removeChild(m_pDisabledOff);
|
||||
this->removeChild(_pDisabledOff);
|
||||
}
|
||||
// 添加新的
|
||||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
}
|
||||
m_pDisabledOff = disabled;
|
||||
_pDisabledOff = disabled;
|
||||
|
||||
_updateState();
|
||||
_updateVisiable();
|
||||
|
|
@ -280,39 +280,39 @@ void e2d::ButtonToggle::setDisabledOff(Node * disabled)
|
|||
|
||||
void e2d::ButtonToggle::_updateState()
|
||||
{
|
||||
if (m_bState)
|
||||
if (_bState)
|
||||
{
|
||||
m_pNormal = m_pNormalOn;
|
||||
m_pMouseover = m_pMouseoverOn;
|
||||
m_pSelected = m_pSelectedOn;
|
||||
m_pDisabled = m_pDisabledOn;
|
||||
_pNormal = _pNormalOn;
|
||||
_pMouseover = _pMouseoverOn;
|
||||
_pSelected = _pSelectedOn;
|
||||
_pDisabled = _pDisabledOn;
|
||||
|
||||
if (m_pNormalOff) m_pNormalOff->setVisiable(false);
|
||||
if (m_pMouseoverOff) m_pMouseoverOff->setVisiable(false);
|
||||
if (m_pSelectedOff) m_pSelectedOff->setVisiable(false);
|
||||
if (m_pDisabledOff) m_pDisabledOff->setVisiable(false);
|
||||
if (_pNormalOff) _pNormalOff->setVisiable(false);
|
||||
if (_pMouseoverOff) _pMouseoverOff->setVisiable(false);
|
||||
if (_pSelectedOff) _pSelectedOff->setVisiable(false);
|
||||
if (_pDisabledOff) _pDisabledOff->setVisiable(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pNormal = m_pNormalOff;
|
||||
m_pMouseover = m_pMouseoverOff;
|
||||
m_pSelected = m_pSelectedOff;
|
||||
m_pDisabled = m_pDisabledOff;
|
||||
_pNormal = _pNormalOff;
|
||||
_pMouseover = _pMouseoverOff;
|
||||
_pSelected = _pSelectedOff;
|
||||
_pDisabled = _pDisabledOff;
|
||||
|
||||
if (m_pNormalOn) m_pNormalOn->setVisiable(false);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setVisiable(false);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setVisiable(false);
|
||||
if (m_pDisabledOn) m_pDisabledOn->setVisiable(false);
|
||||
if (_pNormalOn) _pNormalOn->setVisiable(false);
|
||||
if (_pMouseoverOn) _pMouseoverOn->setVisiable(false);
|
||||
if (_pSelectedOn) _pSelectedOn->setVisiable(false);
|
||||
if (_pDisabledOn) _pDisabledOn->setVisiable(false);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::_runCallback()
|
||||
{
|
||||
m_bState = !m_bState;
|
||||
_bState = !_bState;
|
||||
_updateState();
|
||||
|
||||
if (m_Callback)
|
||||
if (_Callback)
|
||||
{
|
||||
m_Callback();
|
||||
_Callback();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::Menu::Menu()
|
||||
: m_bEnable(true)
|
||||
: _bEnable(true)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HIGHER_THAN_VS2012
|
||||
e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
|
||||
: m_bEnable(true)
|
||||
: _bEnable(true)
|
||||
{
|
||||
for (auto button : vButtons)
|
||||
{
|
||||
|
|
@ -18,7 +18,7 @@ e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
|
|||
#else
|
||||
|
||||
e2d::Menu::Menu(int number, Button * button1, ...)
|
||||
: m_bEnable(true)
|
||||
: _bEnable(true)
|
||||
{
|
||||
Button ** ppButton = &button1;
|
||||
|
||||
|
|
@ -33,21 +33,21 @@ e2d::Menu::Menu(int number, Button * button1, ...)
|
|||
|
||||
bool e2d::Menu::isEnable() const
|
||||
{
|
||||
return m_bEnable;
|
||||
return _bEnable;
|
||||
}
|
||||
|
||||
size_t e2d::Menu::getButtonCount() const
|
||||
{
|
||||
return m_vButtons.size();
|
||||
return _vButtons.size();
|
||||
}
|
||||
|
||||
void e2d::Menu::setEnable(bool enable)
|
||||
{
|
||||
if (m_bEnable != enable)
|
||||
if (_bEnable != enable)
|
||||
{
|
||||
m_bEnable = enable;
|
||||
_bEnable = enable;
|
||||
|
||||
for (auto button : m_vButtons)
|
||||
for (auto button : _vButtons)
|
||||
{
|
||||
button->setEnable(enable);
|
||||
}
|
||||
|
|
@ -59,14 +59,14 @@ void e2d::Menu::addButton(Button * button)
|
|||
if (button)
|
||||
{
|
||||
this->addChild(button);
|
||||
m_vButtons.push_back(button);
|
||||
button->setEnable(m_bEnable);
|
||||
_vButtons.push_back(button);
|
||||
button->setEnable(_bEnable);
|
||||
}
|
||||
}
|
||||
|
||||
bool e2d::Menu::removeButton(Button * button)
|
||||
{
|
||||
if (m_vButtons.empty())
|
||||
if (_vButtons.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -75,14 +75,14 @@ bool e2d::Menu::removeButton(Button * button)
|
|||
|
||||
if (button)
|
||||
{
|
||||
size_t size = m_vButtons.size();
|
||||
size_t size = _vButtons.size();
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
if (m_vButtons[i] == button)
|
||||
if (_vButtons[i] == button)
|
||||
{
|
||||
// ÒÆ³ý°´Å¥Ç°£¬½«ËüÆôÓÃ
|
||||
button->setEnable(true);
|
||||
m_vButtons.erase(m_vButtons.begin() + i);
|
||||
_vButtons.erase(_vButtons.begin() + i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,31 +10,31 @@ static float s_fDefaultPiovtY = 0;
|
|||
static bool s_fDefaultColliderEnabled = true;
|
||||
|
||||
e2d::Node::Node()
|
||||
: m_nOrder(0)
|
||||
, m_fPosX(0)
|
||||
, m_fPosY(0)
|
||||
, m_fWidth(0)
|
||||
, m_fHeight(0)
|
||||
, m_fScaleX(1.0f)
|
||||
, m_fScaleY(1.0f)
|
||||
, m_fRotation(0)
|
||||
, m_fSkewAngleX(0)
|
||||
, m_fSkewAngleY(0)
|
||||
, m_fDisplayOpacity(1.0f)
|
||||
, m_fRealOpacity(1.0f)
|
||||
, m_fPivotX(s_fDefaultPiovtX)
|
||||
, m_fPivotY(s_fDefaultPiovtY)
|
||||
, m_MatriInitial(D2D1::Matrix3x2F::Identity())
|
||||
, m_MatriFinal(D2D1::Matrix3x2F::Identity())
|
||||
, m_bVisiable(true)
|
||||
, m_pCollider(nullptr)
|
||||
, m_pParent(nullptr)
|
||||
, m_pParentScene(nullptr)
|
||||
, m_nHashName(0)
|
||||
, m_bSortChildrenNeeded(false)
|
||||
, m_bTransformNeeded(false)
|
||||
, m_bAutoUpdate(true)
|
||||
, m_bPositionFixed(false)
|
||||
: _nOrder(0)
|
||||
, _fPosX(0)
|
||||
, _fPosY(0)
|
||||
, _fWidth(0)
|
||||
, _fHeight(0)
|
||||
, _fScaleX(1.0f)
|
||||
, _fScaleY(1.0f)
|
||||
, _fRotation(0)
|
||||
, _fSkewAngleX(0)
|
||||
, _fSkewAngleY(0)
|
||||
, _fDisplayOpacity(1.0f)
|
||||
, _fRealOpacity(1.0f)
|
||||
, _fPivotX(s_fDefaultPiovtX)
|
||||
, _fPivotY(s_fDefaultPiovtY)
|
||||
, _MatriInitial(D2D1::Matrix3x2F::Identity())
|
||||
, _MatriFinal(D2D1::Matrix3x2F::Identity())
|
||||
, _bVisiable(true)
|
||||
, _pCollider(nullptr)
|
||||
, _pParent(nullptr)
|
||||
, _pParentScene(nullptr)
|
||||
, _nHashName(0)
|
||||
, _bSortChildrenNeeded(false)
|
||||
, _bTransformNeeded(false)
|
||||
, _bAutoUpdate(true)
|
||||
, _bPositionFixed(false)
|
||||
{
|
||||
if (s_fDefaultColliderEnabled)
|
||||
{
|
||||
|
|
@ -49,14 +49,14 @@ e2d::Node::~Node()
|
|||
|
||||
void e2d::Node::_update()
|
||||
{
|
||||
if (m_bTransformNeeded)
|
||||
if (_bTransformNeeded)
|
||||
{
|
||||
_updateTransform();
|
||||
}
|
||||
|
||||
if (!m_vChildren.empty())
|
||||
if (!_vChildren.empty())
|
||||
{
|
||||
if (m_bSortChildrenNeeded)
|
||||
if (_bSortChildrenNeeded)
|
||||
{
|
||||
// 子节点排序
|
||||
auto sortFunc = [](Node * n1, Node * n2) {
|
||||
|
|
@ -64,20 +64,20 @@ void e2d::Node::_update()
|
|||
};
|
||||
|
||||
std::sort(
|
||||
std::begin(m_vChildren),
|
||||
std::end(m_vChildren),
|
||||
std::begin(_vChildren),
|
||||
std::end(_vChildren),
|
||||
sortFunc
|
||||
);
|
||||
|
||||
m_bSortChildrenNeeded = false;
|
||||
_bSortChildrenNeeded = false;
|
||||
}
|
||||
|
||||
// 遍历子节点
|
||||
size_t size = m_vChildren.size();
|
||||
size_t size = _vChildren.size();
|
||||
size_t i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
auto child = m_vChildren[i];
|
||||
auto child = _vChildren[i];
|
||||
// 访问 Order 小于零的节点
|
||||
if (child->getOrder() < 0)
|
||||
{
|
||||
|
|
@ -89,7 +89,7 @@ void e2d::Node::_update()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_bAutoUpdate)
|
||||
if (_bAutoUpdate)
|
||||
{
|
||||
if (!Game::isPaused())
|
||||
{
|
||||
|
|
@ -100,11 +100,11 @@ void e2d::Node::_update()
|
|||
|
||||
// 访问剩余节点
|
||||
for (; i < size; i++)
|
||||
m_vChildren[i]->_update();
|
||||
_vChildren[i]->_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bAutoUpdate)
|
||||
if (_bAutoUpdate)
|
||||
{
|
||||
if (!Game::isPaused())
|
||||
{
|
||||
|
|
@ -117,18 +117,18 @@ void e2d::Node::_update()
|
|||
|
||||
void e2d::Node::_render()
|
||||
{
|
||||
if (!m_bVisiable)
|
||||
if (!_bVisiable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_vChildren.empty())
|
||||
if (!_vChildren.empty())
|
||||
{
|
||||
size_t size = m_vChildren.size();
|
||||
size_t size = _vChildren.size();
|
||||
size_t i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
auto child = m_vChildren[i];
|
||||
auto child = _vChildren[i];
|
||||
// 访问 Order 小于零的节点
|
||||
if (child->getOrder() < 0)
|
||||
{
|
||||
|
|
@ -141,18 +141,18 @@ void e2d::Node::_render()
|
|||
}
|
||||
|
||||
// 转换渲染器的二维矩阵
|
||||
Renderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
Renderer::getRenderTarget()->SetTransform(_MatriFinal);
|
||||
// 渲染自身
|
||||
this->onRender();
|
||||
|
||||
// 访问剩余节点
|
||||
for (; i < size; i++)
|
||||
m_vChildren[i]->_render();
|
||||
_vChildren[i]->_render();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 转换渲染器的二维矩阵
|
||||
Renderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
Renderer::getRenderTarget()->SetTransform(_MatriFinal);
|
||||
// 渲染自身
|
||||
this->onRender();
|
||||
}
|
||||
|
|
@ -161,13 +161,13 @@ void e2d::Node::_render()
|
|||
void e2d::Node::_drawCollider()
|
||||
{
|
||||
// 绘制自身的几何碰撞体
|
||||
if (m_pCollider && m_pCollider->m_bIsVisiable)
|
||||
if (_pCollider && _pCollider->_bIsVisiable)
|
||||
{
|
||||
m_pCollider->_render();
|
||||
_pCollider->_render();
|
||||
}
|
||||
|
||||
// 绘制所有子节点的几何碰撞体
|
||||
for (auto child : m_vChildren)
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
child->_drawCollider();
|
||||
}
|
||||
|
|
@ -176,30 +176,30 @@ void e2d::Node::_drawCollider()
|
|||
void e2d::Node::_updateSelfTransform()
|
||||
{
|
||||
// 计算中心点坐标
|
||||
D2D1_POINT_2F pivot = { m_fWidth * m_fPivotX, m_fHeight * m_fPivotY };
|
||||
D2D1_POINT_2F pivot = { _fWidth * _fPivotX, _fHeight * _fPivotY };
|
||||
// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
|
||||
m_MatriInitial = D2D1::Matrix3x2F::Scale(
|
||||
m_fScaleX,
|
||||
m_fScaleY,
|
||||
_MatriInitial = D2D1::Matrix3x2F::Scale(
|
||||
_fScaleX,
|
||||
_fScaleY,
|
||||
pivot
|
||||
) * D2D1::Matrix3x2F::Skew(
|
||||
m_fSkewAngleX,
|
||||
m_fSkewAngleY,
|
||||
_fSkewAngleX,
|
||||
_fSkewAngleY,
|
||||
pivot
|
||||
) * D2D1::Matrix3x2F::Rotation(
|
||||
m_fRotation,
|
||||
_fRotation,
|
||||
pivot
|
||||
) * D2D1::Matrix3x2F::Translation(
|
||||
m_fPosX,
|
||||
m_fPosY
|
||||
_fPosX,
|
||||
_fPosY
|
||||
);
|
||||
// 根据自身中心点变换 Final 矩阵
|
||||
m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
||||
_MatriFinal = _MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
||||
// 和父节点矩阵相乘
|
||||
if (!m_bPositionFixed && m_pParent)
|
||||
if (!_bPositionFixed && _pParent)
|
||||
{
|
||||
m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial;
|
||||
m_MatriFinal = m_MatriFinal * m_pParent->m_MatriInitial;
|
||||
_MatriInitial = _MatriInitial * _pParent->_MatriInitial;
|
||||
_MatriFinal = _MatriFinal * _pParent->_MatriInitial;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,14 +208,14 @@ void e2d::Node::_updateTransform()
|
|||
// 计算自身的转换矩阵
|
||||
_updateSelfTransform();
|
||||
// 绑定于自身的碰撞体也进行相应转换
|
||||
if (m_pCollider)
|
||||
if (_pCollider)
|
||||
{
|
||||
m_pCollider->_transform();
|
||||
_pCollider->_transform();
|
||||
}
|
||||
// 标志已执行过变换
|
||||
m_bTransformNeeded = false;
|
||||
_bTransformNeeded = false;
|
||||
// 遍历子节点下的所有节点
|
||||
for (auto child : this->m_vChildren)
|
||||
for (auto child : this->_vChildren)
|
||||
{
|
||||
child->_updateTransform();
|
||||
}
|
||||
|
|
@ -223,11 +223,11 @@ void e2d::Node::_updateTransform()
|
|||
|
||||
void e2d::Node::_updateOpacity()
|
||||
{
|
||||
if (m_pParent)
|
||||
if (_pParent)
|
||||
{
|
||||
m_fDisplayOpacity = m_fRealOpacity * m_pParent->m_fDisplayOpacity;
|
||||
_fDisplayOpacity = _fRealOpacity * _pParent->_fDisplayOpacity;
|
||||
}
|
||||
for (auto child : m_vChildren)
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
child->_updateOpacity();
|
||||
}
|
||||
|
|
@ -235,67 +235,67 @@ void e2d::Node::_updateOpacity()
|
|||
|
||||
bool e2d::Node::isVisiable() const
|
||||
{
|
||||
return m_bVisiable;
|
||||
return _bVisiable;
|
||||
}
|
||||
|
||||
e2d::String e2d::Node::getName() const
|
||||
{
|
||||
return m_sName;
|
||||
return _sName;
|
||||
}
|
||||
|
||||
unsigned int e2d::Node::getHashName() const
|
||||
{
|
||||
return m_nHashName;
|
||||
return _nHashName;
|
||||
}
|
||||
|
||||
double e2d::Node::getPosX() const
|
||||
{
|
||||
return m_fPosX;
|
||||
return _fPosX;
|
||||
}
|
||||
|
||||
double e2d::Node::getPosY() const
|
||||
{
|
||||
return m_fPosY;
|
||||
return _fPosY;
|
||||
}
|
||||
|
||||
e2d::Point e2d::Node::getPos() const
|
||||
{
|
||||
return Point(m_fPosX, m_fPosY);
|
||||
return Point(_fPosX, _fPosY);
|
||||
}
|
||||
|
||||
double e2d::Node::getWidth() const
|
||||
{
|
||||
return m_fWidth * m_fScaleX;
|
||||
return _fWidth * _fScaleX;
|
||||
}
|
||||
|
||||
double e2d::Node::getHeight() const
|
||||
{
|
||||
return m_fHeight * m_fScaleY;
|
||||
return _fHeight * _fScaleY;
|
||||
}
|
||||
|
||||
double e2d::Node::getRealWidth() const
|
||||
{
|
||||
return m_fWidth;
|
||||
return _fWidth;
|
||||
}
|
||||
|
||||
double e2d::Node::getRealHeight() const
|
||||
{
|
||||
return m_fHeight;
|
||||
return _fHeight;
|
||||
}
|
||||
|
||||
e2d::Size e2d::Node::getRealSize() const
|
||||
{
|
||||
return Size(m_fWidth, m_fHeight);
|
||||
return Size(_fWidth, _fHeight);
|
||||
}
|
||||
|
||||
double e2d::Node::getPivotX() const
|
||||
{
|
||||
return m_fPivotX;
|
||||
return _fPivotX;
|
||||
}
|
||||
|
||||
double e2d::Node::getPivotY() const
|
||||
{
|
||||
return m_fPivotY;
|
||||
return _fPivotY;
|
||||
}
|
||||
|
||||
e2d::Size e2d::Node::getSize() const
|
||||
|
|
@ -305,76 +305,76 @@ e2d::Size e2d::Node::getSize() const
|
|||
|
||||
double e2d::Node::getScaleX() const
|
||||
{
|
||||
return m_fScaleX;
|
||||
return _fScaleX;
|
||||
}
|
||||
|
||||
double e2d::Node::getScaleY() const
|
||||
{
|
||||
return m_fScaleY;
|
||||
return _fScaleY;
|
||||
}
|
||||
|
||||
double e2d::Node::getSkewX() const
|
||||
{
|
||||
return m_fSkewAngleX;
|
||||
return _fSkewAngleX;
|
||||
}
|
||||
|
||||
double e2d::Node::getSkewY() const
|
||||
{
|
||||
return m_fSkewAngleY;
|
||||
return _fSkewAngleY;
|
||||
}
|
||||
|
||||
double e2d::Node::getRotation() const
|
||||
{
|
||||
return m_fRotation;
|
||||
return _fRotation;
|
||||
}
|
||||
|
||||
double e2d::Node::getOpacity() const
|
||||
{
|
||||
return m_fRealOpacity;
|
||||
return _fRealOpacity;
|
||||
}
|
||||
|
||||
e2d::NodeProperty e2d::Node::getProperty() const
|
||||
{
|
||||
NodeProperty prop;
|
||||
prop.visable = m_bVisiable;
|
||||
prop.posX = m_fPosX;
|
||||
prop.posY = m_fPosY;
|
||||
prop.width = m_fWidth;
|
||||
prop.height = m_fHeight;
|
||||
prop.opacity = m_fRealOpacity;
|
||||
prop.pivotX = m_fPivotX;
|
||||
prop.pivotY = m_fPivotY;
|
||||
prop.scaleX = m_fScaleX;
|
||||
prop.scaleY = m_fScaleY;
|
||||
prop.rotation = m_fRotation;
|
||||
prop.skewAngleX = m_fSkewAngleX;
|
||||
prop.skewAngleY = m_fSkewAngleY;
|
||||
prop.visable = _bVisiable;
|
||||
prop.posX = _fPosX;
|
||||
prop.posY = _fPosY;
|
||||
prop.width = _fWidth;
|
||||
prop.height = _fHeight;
|
||||
prop.opacity = _fRealOpacity;
|
||||
prop.pivotX = _fPivotX;
|
||||
prop.pivotY = _fPivotY;
|
||||
prop.scaleX = _fScaleX;
|
||||
prop.scaleY = _fScaleY;
|
||||
prop.rotation = _fRotation;
|
||||
prop.skewAngleX = _fSkewAngleX;
|
||||
prop.skewAngleY = _fSkewAngleY;
|
||||
return prop;
|
||||
}
|
||||
|
||||
e2d::Collider * e2d::Node::getCollider() const
|
||||
{
|
||||
return m_pCollider;
|
||||
return _pCollider;
|
||||
}
|
||||
|
||||
int e2d::Node::getOrder() const
|
||||
{
|
||||
return m_nOrder;
|
||||
return _nOrder;
|
||||
}
|
||||
|
||||
void e2d::Node::setOrder(int order)
|
||||
{
|
||||
m_nOrder = order;
|
||||
_nOrder = order;
|
||||
}
|
||||
|
||||
void e2d::Node::setPosX(double x)
|
||||
{
|
||||
this->setPos(x, m_fPosY);
|
||||
this->setPos(x, _fPosY);
|
||||
}
|
||||
|
||||
void e2d::Node::setPosY(double y)
|
||||
{
|
||||
this->setPos(m_fPosX, y);
|
||||
this->setPos(_fPosX, y);
|
||||
}
|
||||
|
||||
void e2d::Node::setPos(const Point & p)
|
||||
|
|
@ -384,21 +384,21 @@ void e2d::Node::setPos(const Point & p)
|
|||
|
||||
void e2d::Node::setPos(double x, double y)
|
||||
{
|
||||
if (m_fPosX == x && m_fPosY == y)
|
||||
if (_fPosX == x && _fPosY == y)
|
||||
return;
|
||||
|
||||
m_fPosX = static_cast<float>(x);
|
||||
m_fPosY = static_cast<float>(y);
|
||||
m_bTransformNeeded = true;
|
||||
_fPosX = static_cast<float>(x);
|
||||
_fPosY = static_cast<float>(y);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setPosFixed(bool fixed)
|
||||
{
|
||||
if (m_bPositionFixed == fixed)
|
||||
if (_bPositionFixed == fixed)
|
||||
return;
|
||||
|
||||
m_bPositionFixed = fixed;
|
||||
m_bTransformNeeded = true;
|
||||
_bPositionFixed = fixed;
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::movePosX(double x)
|
||||
|
|
@ -413,7 +413,7 @@ void e2d::Node::movePosY(double y)
|
|||
|
||||
void e2d::Node::movePos(double x, double y)
|
||||
{
|
||||
this->setPos(m_fPosX + x, m_fPosY + y);
|
||||
this->setPos(_fPosX + x, _fPosY + y);
|
||||
}
|
||||
|
||||
void e2d::Node::movePos(const Vector & v)
|
||||
|
|
@ -423,12 +423,12 @@ void e2d::Node::movePos(const Vector & v)
|
|||
|
||||
void e2d::Node::setScaleX(double scaleX)
|
||||
{
|
||||
this->setScale(scaleX, m_fScaleY);
|
||||
this->setScale(scaleX, _fScaleY);
|
||||
}
|
||||
|
||||
void e2d::Node::setScaleY(double scaleY)
|
||||
{
|
||||
this->setScale(m_fScaleX, scaleY);
|
||||
this->setScale(_fScaleX, scaleY);
|
||||
}
|
||||
|
||||
void e2d::Node::setScale(double scale)
|
||||
|
|
@ -438,91 +438,91 @@ void e2d::Node::setScale(double scale)
|
|||
|
||||
void e2d::Node::setScale(double scaleX, double scaleY)
|
||||
{
|
||||
if (m_fScaleX == scaleX && m_fScaleY == scaleY)
|
||||
if (_fScaleX == scaleX && _fScaleY == scaleY)
|
||||
return;
|
||||
|
||||
m_fScaleX = static_cast<float>(scaleX);
|
||||
m_fScaleY = static_cast<float>(scaleY);
|
||||
m_bTransformNeeded = true;
|
||||
_fScaleX = static_cast<float>(scaleX);
|
||||
_fScaleY = static_cast<float>(scaleY);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setSkewX(double angleX)
|
||||
{
|
||||
this->setSkew(angleX, m_fSkewAngleY);
|
||||
this->setSkew(angleX, _fSkewAngleY);
|
||||
}
|
||||
|
||||
void e2d::Node::setSkewY(double angleY)
|
||||
{
|
||||
this->setSkew(m_fSkewAngleX, angleY);
|
||||
this->setSkew(_fSkewAngleX, angleY);
|
||||
}
|
||||
|
||||
void e2d::Node::setSkew(double angleX, double angleY)
|
||||
{
|
||||
if (m_fSkewAngleX == angleX && m_fSkewAngleY == angleY)
|
||||
if (_fSkewAngleX == angleX && _fSkewAngleY == angleY)
|
||||
return;
|
||||
|
||||
m_fSkewAngleX = static_cast<float>(angleX);
|
||||
m_fSkewAngleY = static_cast<float>(angleY);
|
||||
m_bTransformNeeded = true;
|
||||
_fSkewAngleX = static_cast<float>(angleX);
|
||||
_fSkewAngleY = static_cast<float>(angleY);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setRotation(double angle)
|
||||
{
|
||||
if (m_fRotation == angle)
|
||||
if (_fRotation == angle)
|
||||
return;
|
||||
|
||||
m_fRotation = static_cast<float>(angle);
|
||||
m_bTransformNeeded = true;
|
||||
_fRotation = static_cast<float>(angle);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setOpacity(double opacity)
|
||||
{
|
||||
if (m_fRealOpacity == opacity)
|
||||
if (_fRealOpacity == opacity)
|
||||
return;
|
||||
|
||||
m_fDisplayOpacity = m_fRealOpacity = min(max(static_cast<float>(opacity), 0), 1);
|
||||
_fDisplayOpacity = _fRealOpacity = min(max(static_cast<float>(opacity), 0), 1);
|
||||
// 更新节点透明度
|
||||
_updateOpacity();
|
||||
}
|
||||
|
||||
void e2d::Node::setPivotX(double pivotX)
|
||||
{
|
||||
this->setPivot(pivotX, m_fPivotY);
|
||||
this->setPivot(pivotX, _fPivotY);
|
||||
}
|
||||
|
||||
void e2d::Node::setPivotY(double pivotY)
|
||||
{
|
||||
this->setPivot(m_fPivotX, pivotY);
|
||||
this->setPivot(_fPivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::Node::setPivot(double pivotX, double pivotY)
|
||||
{
|
||||
if (m_fPivotX == pivotX && m_fPivotY == pivotY)
|
||||
if (_fPivotX == pivotX && _fPivotY == pivotY)
|
||||
return;
|
||||
|
||||
m_fPivotX = min(max(static_cast<float>(pivotX), 0), 1);
|
||||
m_fPivotY = min(max(static_cast<float>(pivotY), 0), 1);
|
||||
m_bTransformNeeded = true;
|
||||
_fPivotX = min(max(static_cast<float>(pivotX), 0), 1);
|
||||
_fPivotY = min(max(static_cast<float>(pivotY), 0), 1);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setWidth(double width)
|
||||
{
|
||||
this->setSize(width, m_fHeight);
|
||||
this->setSize(width, _fHeight);
|
||||
}
|
||||
|
||||
void e2d::Node::setHeight(double height)
|
||||
{
|
||||
this->setSize(m_fWidth, height);
|
||||
this->setSize(_fWidth, height);
|
||||
}
|
||||
|
||||
void e2d::Node::setSize(double width, double height)
|
||||
{
|
||||
if (m_fWidth == width && m_fHeight == height)
|
||||
if (_fWidth == width && _fHeight == height)
|
||||
return;
|
||||
|
||||
m_fWidth = static_cast<float>(width);
|
||||
m_fHeight = static_cast<float>(height);
|
||||
m_bTransformNeeded = true;
|
||||
_fWidth = static_cast<float>(width);
|
||||
_fHeight = static_cast<float>(height);
|
||||
_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::Node::setSize(Size size)
|
||||
|
|
@ -575,26 +575,26 @@ void e2d::Node::setCollider(ColliderType nColliderType)
|
|||
void e2d::Node::setCollider(Collider * pCollider)
|
||||
{
|
||||
// 删除旧的碰撞体
|
||||
ColliderManager::__removeCollider(m_pCollider);
|
||||
ColliderManager::__removeCollider(_pCollider);
|
||||
// 添加新的碰撞体
|
||||
ColliderManager::__addCollider(pCollider);
|
||||
|
||||
if (pCollider)
|
||||
{
|
||||
// 双向绑定
|
||||
this->m_pCollider = pCollider;
|
||||
pCollider->m_pParentNode = this;
|
||||
this->_pCollider = pCollider;
|
||||
pCollider->_pParentNode = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_pCollider = nullptr;
|
||||
this->_pCollider = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Node::addColliableName(const String& collliderName)
|
||||
{
|
||||
unsigned int hash = collliderName.getHashCode();
|
||||
m_vColliders.insert(hash);
|
||||
_vColliders.insert(hash);
|
||||
}
|
||||
|
||||
#ifdef HIGHER_THAN_VS2012
|
||||
|
|
@ -610,7 +610,7 @@ void e2d::Node::addColliableName(const std::initializer_list<String>& vColllider
|
|||
void e2d::Node::removeColliableName(const String& collliderName)
|
||||
{
|
||||
unsigned int hash = collliderName.getHashCode();
|
||||
m_vColliders.erase(hash);
|
||||
_vColliders.erase(hash);
|
||||
}
|
||||
|
||||
void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
||||
|
|
@ -619,32 +619,32 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
|||
|
||||
if (child)
|
||||
{
|
||||
ASSERT(child->m_pParent == nullptr, "Node already added. It can't be added again!");
|
||||
ASSERT(child->_pParent == nullptr, "Node already added. It can't be added again!");
|
||||
|
||||
for (Node * parent = this; parent != nullptr; parent = parent->getParent())
|
||||
{
|
||||
ASSERT(child != parent, "A Node cannot be the child of his own children!");
|
||||
}
|
||||
|
||||
m_vChildren.push_back(child);
|
||||
_vChildren.push_back(child);
|
||||
|
||||
child->setOrder(order);
|
||||
|
||||
child->retain();
|
||||
|
||||
child->m_pParent = this;
|
||||
child->_pParent = this;
|
||||
|
||||
if (this->m_pParentScene)
|
||||
if (this->_pParentScene)
|
||||
{
|
||||
child->_setParentScene(this->m_pParentScene);
|
||||
child->_setParentScene(this->_pParentScene);
|
||||
}
|
||||
|
||||
// 更新子节点透明度
|
||||
child->_updateOpacity();
|
||||
// 更新节点转换
|
||||
child->m_bTransformNeeded = true;
|
||||
child->_bTransformNeeded = true;
|
||||
// 更新子节点排序
|
||||
m_bSortChildrenNeeded = true;
|
||||
_bSortChildrenNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -660,12 +660,12 @@ void e2d::Node::addChild(const std::initializer_list<Node*>& vNodes, int order)
|
|||
|
||||
e2d::Node * e2d::Node::getParent() const
|
||||
{
|
||||
return m_pParent;
|
||||
return _pParent;
|
||||
}
|
||||
|
||||
e2d::Scene * e2d::Node::getParentScene() const
|
||||
{
|
||||
return m_pParentScene;
|
||||
return _pParentScene;
|
||||
}
|
||||
|
||||
std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const
|
||||
|
|
@ -673,10 +673,10 @@ std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const
|
|||
std::vector<Node*> vChildren;
|
||||
unsigned int hash = name.getHashCode();
|
||||
|
||||
for (auto child : m_vChildren)
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
|
||||
if (child->m_nHashName == hash && child->m_sName == name)
|
||||
if (child->_nHashName == hash && child->_sName == name)
|
||||
{
|
||||
vChildren.push_back(child);
|
||||
}
|
||||
|
|
@ -688,10 +688,10 @@ e2d::Node * e2d::Node::getChild(const String& name) const
|
|||
{
|
||||
unsigned int hash = name.getHashCode();
|
||||
|
||||
for (auto child : m_vChildren)
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
|
||||
if (child->m_nHashName == hash && child->m_sName == name)
|
||||
if (child->_nHashName == hash && child->_sName == name)
|
||||
{
|
||||
return child;
|
||||
}
|
||||
|
|
@ -701,19 +701,19 @@ e2d::Node * e2d::Node::getChild(const String& name) const
|
|||
|
||||
std::vector<e2d::Node*> e2d::Node::getAllChildren() const
|
||||
{
|
||||
return m_vChildren;
|
||||
return _vChildren;
|
||||
}
|
||||
|
||||
int e2d::Node::getChildrenCount() const
|
||||
{
|
||||
return static_cast<int>(m_vChildren.size());
|
||||
return static_cast<int>(_vChildren.size());
|
||||
}
|
||||
|
||||
void e2d::Node::removeFromParent()
|
||||
{
|
||||
if (m_pParent)
|
||||
if (_pParent)
|
||||
{
|
||||
m_pParent->removeChild(this);
|
||||
_pParent->removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -721,22 +721,22 @@ bool e2d::Node::removeChild(Node * child)
|
|||
{
|
||||
WARN_IF(child == nullptr, "Node::removeChildren NULL pointer exception.");
|
||||
|
||||
if (m_vChildren.empty())
|
||||
if (_vChildren.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child)
|
||||
{
|
||||
size_t size = m_vChildren.size();
|
||||
size_t size = _vChildren.size();
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
if (m_vChildren[i] == child)
|
||||
if (_vChildren[i] == child)
|
||||
{
|
||||
m_vChildren.erase(m_vChildren.begin() + i);
|
||||
child->m_pParent = nullptr;
|
||||
_vChildren.erase(_vChildren.begin() + i);
|
||||
child->_pParent = nullptr;
|
||||
|
||||
if (child->m_pParentScene)
|
||||
if (child->_pParentScene)
|
||||
{
|
||||
child->_setParentScene(nullptr);
|
||||
}
|
||||
|
|
@ -753,7 +753,7 @@ void e2d::Node::removeChildren(const String& childName)
|
|||
{
|
||||
WARN_IF(childName.isEmpty(), "Invalid Node name.");
|
||||
|
||||
if (m_vChildren.empty())
|
||||
if (_vChildren.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -761,15 +761,15 @@ void e2d::Node::removeChildren(const String& childName)
|
|||
// 计算名称 Hash 值
|
||||
unsigned int hash = childName.getHashCode();
|
||||
|
||||
size_t size = m_vChildren.size();
|
||||
size_t size = _vChildren.size();
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
auto child = m_vChildren[i];
|
||||
if (child->m_nHashName == hash && child->m_sName == childName)
|
||||
auto child = _vChildren[i];
|
||||
if (child->_nHashName == hash && child->_sName == childName)
|
||||
{
|
||||
m_vChildren.erase(m_vChildren.begin() + i);
|
||||
child->m_pParent = nullptr;
|
||||
if (child->m_pParentScene)
|
||||
_vChildren.erase(_vChildren.begin() + i);
|
||||
child->_pParent = nullptr;
|
||||
if (child->_pParentScene)
|
||||
{
|
||||
child->_setParentScene(nullptr);
|
||||
}
|
||||
|
|
@ -781,28 +781,20 @@ void e2d::Node::removeChildren(const String& childName)
|
|||
void e2d::Node::clearAllChildren()
|
||||
{
|
||||
// 所有节点的引用计数减一
|
||||
for (auto child : m_vChildren)
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
child->release();
|
||||
}
|
||||
// 清空储存节点的容器
|
||||
m_vChildren.clear();
|
||||
_vChildren.clear();
|
||||
}
|
||||
|
||||
void e2d::Node::runAction(ActionBase * action)
|
||||
{
|
||||
if (this != action->getTarget())
|
||||
{
|
||||
WARN_IF(
|
||||
nullptr != action->getTarget(),
|
||||
"The action has already got a target, The clone of the action will be created automatically!"
|
||||
);
|
||||
|
||||
if (nullptr != action->getTarget())
|
||||
{
|
||||
action = action->clone();
|
||||
}
|
||||
ActionManager::__startAction(action, this);
|
||||
ASSERT(action->getTarget() == nullptr, "The action has already got a target!");
|
||||
ActionManager::start(action, this, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -881,13 +873,13 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
{
|
||||
BOOL ret = 0;
|
||||
// 如果存在碰撞体,用碰撞体判断
|
||||
if (m_pCollider)
|
||||
if (_pCollider)
|
||||
{
|
||||
m_pCollider->getD2dGeometry()->FillContainsPoint(
|
||||
_pCollider->getD2dGeometry()->FillContainsPoint(
|
||||
D2D1::Point2F(
|
||||
static_cast<float>(point.x),
|
||||
static_cast<float>(point.y)),
|
||||
m_MatriFinal,
|
||||
_MatriFinal,
|
||||
&ret
|
||||
);
|
||||
}
|
||||
|
|
@ -896,7 +888,7 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
// 为节点创建一个临时碰撞体
|
||||
ID2D1RectangleGeometry * rect;
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
D2D1::RectF(0, 0, _fWidth, _fHeight),
|
||||
&rect
|
||||
);
|
||||
// 判断点是否在碰撞体内
|
||||
|
|
@ -904,7 +896,7 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
D2D1::Point2F(
|
||||
static_cast<float>(point.x),
|
||||
static_cast<float>(point.y)),
|
||||
m_MatriFinal,
|
||||
_MatriFinal,
|
||||
&ret
|
||||
);
|
||||
// 删除临时创建的碰撞体
|
||||
|
|
@ -919,12 +911,12 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool e2d::Node::isIntersectWith(const Node * pNode) const
|
||||
bool e2d::Node::isIntersectWith(const Node * node) const
|
||||
{
|
||||
// 如果存在碰撞体,用碰撞体判断
|
||||
if (this->m_pCollider && pNode->m_pCollider)
|
||||
if (this->_pCollider && node->_pCollider)
|
||||
{
|
||||
Relation relation = this->m_pCollider->getRelationWith(pNode->m_pCollider);
|
||||
Relation relation = this->_pCollider->getRelationWith(node->_pCollider);
|
||||
if ((relation != Relation::UNKNOWN) &&
|
||||
(relation != Relation::DISJOINT))
|
||||
{
|
||||
|
|
@ -941,24 +933,24 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
|
||||
// 根据自身大小位置创建矩形
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
D2D1::RectF(0, 0, _fWidth, _fHeight),
|
||||
&pRect1
|
||||
);
|
||||
// 根据二维矩阵进行转换
|
||||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
pRect1,
|
||||
m_MatriFinal,
|
||||
_MatriFinal,
|
||||
&pCollider
|
||||
);
|
||||
// 根据相比较节点的大小位置创建矩形
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(0, 0, pNode->m_fWidth, pNode->m_fHeight),
|
||||
D2D1::RectF(0, 0, node->_fWidth, node->_fHeight),
|
||||
&pRect2
|
||||
);
|
||||
// 获取相交状态
|
||||
pCollider->CompareWithGeometry(
|
||||
pRect2,
|
||||
pNode->m_MatriFinal,
|
||||
node->_MatriFinal,
|
||||
&relation
|
||||
);
|
||||
// 删除临时创建的碰撞体
|
||||
|
|
@ -977,7 +969,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
|
||||
void e2d::Node::setAutoUpdate(bool bAutoUpdate)
|
||||
{
|
||||
m_bAutoUpdate = bAutoUpdate;
|
||||
_bAutoUpdate = bAutoUpdate;
|
||||
}
|
||||
|
||||
void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY)
|
||||
|
|
@ -994,8 +986,8 @@ void e2d::Node::setDefaultColliderEnable(bool enable)
|
|||
void e2d::Node::destroy()
|
||||
{
|
||||
ActionManager::__clearAllBindedWith(this);
|
||||
ColliderManager::__removeCollider(m_pCollider);
|
||||
for (auto child : m_vChildren)
|
||||
ColliderManager::__removeCollider(_pCollider);
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
SafeRelease(&child);
|
||||
}
|
||||
|
|
@ -1018,26 +1010,26 @@ void e2d::Node::stopAllActions()
|
|||
|
||||
void e2d::Node::setVisiable(bool value)
|
||||
{
|
||||
m_bVisiable = value;
|
||||
_bVisiable = value;
|
||||
}
|
||||
|
||||
void e2d::Node::setName(const String& name)
|
||||
{
|
||||
WARN_IF(name.isEmpty(), "Invalid Node name.");
|
||||
|
||||
if (!name.isEmpty() && m_sName != name)
|
||||
if (!name.isEmpty() && _sName != name)
|
||||
{
|
||||
// 保存节点名
|
||||
m_sName = name;
|
||||
_sName = name;
|
||||
// 保存节点 Hash 名
|
||||
m_nHashName = name.getHashCode();
|
||||
_nHashName = name.getHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Node::_setParentScene(Scene * scene)
|
||||
{
|
||||
m_pParentScene = scene;
|
||||
for (auto child : m_vChildren)
|
||||
_pParentScene = scene;
|
||||
for (auto child : _vChildren)
|
||||
{
|
||||
child->_setParentScene(scene);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "..\..\e2dshape.h"
|
||||
|
||||
e2d::Circle::Circle()
|
||||
: m_fRadius(0)
|
||||
: _fRadius(0)
|
||||
{
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
|
@ -32,28 +32,28 @@ e2d::Circle::~Circle()
|
|||
|
||||
double e2d::Circle::getRadius() const
|
||||
{
|
||||
return m_fRadius;
|
||||
return _fRadius;
|
||||
}
|
||||
|
||||
void e2d::Circle::setRadius(double radius)
|
||||
{
|
||||
m_fRadius = static_cast<float>(radius);
|
||||
_fRadius = static_cast<float>(radius);
|
||||
Node::setSize(radius * 2, radius * 2);
|
||||
}
|
||||
|
||||
void e2d::Circle::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadius, m_fRadius), m_fRadius, m_fRadius),
|
||||
D2D1::Ellipse(D2D1::Point2F(_fRadius, _fRadius), _fRadius, _fRadius),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Circle::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadius, m_fRadius), m_fRadius, m_fRadius),
|
||||
D2D1::Ellipse(D2D1::Point2F(_fRadius, _fRadius), _fRadius, _fRadius),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "..\..\e2dshape.h"
|
||||
|
||||
e2d::Ellipse::Ellipse()
|
||||
: m_fRadiusX(0)
|
||||
, m_fRadiusY(0)
|
||||
: _fRadiusX(0)
|
||||
, _fRadiusY(0)
|
||||
{
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
|
@ -36,39 +36,39 @@ e2d::Ellipse::~Ellipse()
|
|||
|
||||
double e2d::Ellipse::getRadiusX() const
|
||||
{
|
||||
return m_fRadiusX;
|
||||
return _fRadiusX;
|
||||
}
|
||||
|
||||
double e2d::Ellipse::getRadiusY() const
|
||||
{
|
||||
return m_fRadiusY;
|
||||
return _fRadiusY;
|
||||
}
|
||||
|
||||
void e2d::Ellipse::setRadiusX(double radiusX)
|
||||
{
|
||||
m_fRadiusX = static_cast<float>(radiusX);
|
||||
_fRadiusX = static_cast<float>(radiusX);
|
||||
Node::setWidth(radiusX * 2);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::setRadiusY(double radiusY)
|
||||
{
|
||||
m_fRadiusY = static_cast<float>(radiusY);
|
||||
_fRadiusY = static_cast<float>(radiusY);
|
||||
Node::setHeight(radiusY * 2);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadiusX, m_fRadiusY), m_fRadiusX, m_fRadiusY),
|
||||
D2D1::Ellipse(D2D1::Point2F(_fRadiusX, _fRadiusY), _fRadiusX, _fRadiusY),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadiusX, m_fRadiusY), m_fRadiusX, m_fRadiusY),
|
||||
D2D1::Ellipse(D2D1::Point2F(_fRadiusX, _fRadiusY), _fRadiusX, _fRadiusY),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,16 +35,16 @@ e2d::Rect::~Rect()
|
|||
void e2d::Rect::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawRectangle(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
D2D1::RectF(0, 0, _fWidth, _fHeight),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Rect::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillRectangle(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
D2D1::RectF(0, 0, _fWidth, _fHeight),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
#include "..\..\e2dshape.h"
|
||||
|
||||
e2d::RoundRect::RoundRect()
|
||||
: m_fRadiusX(0)
|
||||
, m_fRadiusY(0)
|
||||
: _fRadiusX(0)
|
||||
, _fRadiusY(0)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(double width, double height, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
: _fRadiusX(static_cast<float>(radiusX))
|
||||
, _fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(Size size, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
: _fRadiusX(static_cast<float>(radiusX))
|
||||
, _fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setSize(size);
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(double top, double left, double width, double height, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
: _fRadiusX(static_cast<float>(radiusX))
|
||||
, _fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(top, left);
|
||||
|
|
@ -30,8 +30,8 @@ e2d::RoundRect::RoundRect(double top, double left, double width, double height,
|
|||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(Point topLeft, Size size, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
: _fRadiusX(static_cast<float>(radiusX))
|
||||
, _fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(topLeft);
|
||||
|
|
@ -44,37 +44,37 @@ e2d::RoundRect::~RoundRect()
|
|||
|
||||
double e2d::RoundRect::getRadiusX() const
|
||||
{
|
||||
return m_fRadiusX;
|
||||
return _fRadiusX;
|
||||
}
|
||||
|
||||
double e2d::RoundRect::getRadiusY() const
|
||||
{
|
||||
return m_fRadiusY;
|
||||
return _fRadiusY;
|
||||
}
|
||||
|
||||
void e2d::RoundRect::setRadiusX(double radiusX)
|
||||
{
|
||||
m_fRadiusX = static_cast<float>(radiusX);
|
||||
_fRadiusX = static_cast<float>(radiusX);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::setRadiusY(double radiusY)
|
||||
{
|
||||
m_fRadiusY = static_cast<float>(radiusY);
|
||||
_fRadiusY = static_cast<float>(radiusY);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawRoundedRectangle(
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, m_fWidth, m_fHeight), m_fRadiusX, m_fRadiusY),
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, _fWidth, _fHeight), _fRadiusX, _fRadiusY),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillRoundedRectangle(
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, m_fWidth, m_fHeight), m_fRadiusX, m_fRadiusY),
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, _fWidth, _fHeight), _fRadiusX, _fRadiusY),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "..\..\e2dshape.h"
|
||||
|
||||
e2d::Shape::Shape()
|
||||
: m_nStyle(ShapeStyle::SOLID)
|
||||
, m_nFillColor(Color::WHITE)
|
||||
, m_nLineColor(Color::BLUE, 0.5)
|
||||
, m_fStrokeWidth(1)
|
||||
: _nStyle(ShapeStyle::SOLID)
|
||||
, _nFillColor(Color::WHITE)
|
||||
, _nLineColor(Color::BLUE, 0.5)
|
||||
, _fStrokeWidth(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -15,30 +15,30 @@ e2d::Shape::~Shape()
|
|||
void e2d::Shape::onRender()
|
||||
{
|
||||
auto pBrush = Renderer::getSolidColorBrush();
|
||||
pBrush->SetOpacity(m_fDisplayOpacity);
|
||||
pBrush->SetOpacity(_fDisplayOpacity);
|
||||
|
||||
switch (m_nStyle)
|
||||
switch (_nStyle)
|
||||
{
|
||||
case ShapeStyle::FILL:
|
||||
{
|
||||
pBrush->SetColor(m_nFillColor.toColorF());
|
||||
pBrush->SetColor(_nFillColor.toColorF());
|
||||
this->_renderFill();
|
||||
|
||||
pBrush->SetColor(m_nLineColor.toColorF());
|
||||
pBrush->SetColor(_nLineColor.toColorF());
|
||||
this->_renderLine();
|
||||
break;
|
||||
}
|
||||
|
||||
case ShapeStyle::ROUND:
|
||||
{
|
||||
pBrush->SetColor(m_nLineColor.toColorF());
|
||||
pBrush->SetColor(_nLineColor.toColorF());
|
||||
this->_renderLine();
|
||||
break;
|
||||
}
|
||||
|
||||
case ShapeStyle::SOLID:
|
||||
{
|
||||
pBrush->SetColor(m_nFillColor.toColorF());
|
||||
pBrush->SetColor(_nFillColor.toColorF());
|
||||
this->_renderFill();
|
||||
break;
|
||||
}
|
||||
|
|
@ -50,40 +50,40 @@ void e2d::Shape::onRender()
|
|||
|
||||
e2d::Color e2d::Shape::getFillColor() const
|
||||
{
|
||||
return m_nFillColor;
|
||||
return _nFillColor;
|
||||
}
|
||||
|
||||
e2d::Color e2d::Shape::getLineColor() const
|
||||
{
|
||||
return m_nLineColor;
|
||||
return _nLineColor;
|
||||
}
|
||||
|
||||
double e2d::Shape::getStrokeWidth() const
|
||||
{
|
||||
return m_fStrokeWidth;
|
||||
return _fStrokeWidth;
|
||||
}
|
||||
|
||||
e2d::ShapeStyle e2d::Shape::getStyle() const
|
||||
{
|
||||
return m_nStyle;
|
||||
return _nStyle;
|
||||
}
|
||||
|
||||
void e2d::Shape::setFillColor(Color fillColor)
|
||||
{
|
||||
m_nFillColor = fillColor;
|
||||
_nFillColor = fillColor;
|
||||
}
|
||||
|
||||
void e2d::Shape::setLineColor(Color lineColor)
|
||||
{
|
||||
m_nLineColor = lineColor;
|
||||
_nLineColor = lineColor;
|
||||
}
|
||||
|
||||
void e2d::Shape::setStrokeWidth(double strokeWidth)
|
||||
{
|
||||
m_fStrokeWidth = static_cast<float>(strokeWidth);
|
||||
_fStrokeWidth = static_cast<float>(strokeWidth);
|
||||
}
|
||||
|
||||
void e2d::Shape::setStyle(ShapeStyle style)
|
||||
{
|
||||
m_nStyle = style;
|
||||
_nStyle = style;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,37 +2,37 @@
|
|||
|
||||
|
||||
e2d::Sprite::Sprite()
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Sprite::Sprite(Image * image)
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
open(image);
|
||||
}
|
||||
|
||||
e2d::Sprite::Sprite(const String& filePath)
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
open(filePath);
|
||||
}
|
||||
|
||||
e2d::Sprite::Sprite(int resNameId, const String& resType)
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
open(resNameId, resType);
|
||||
}
|
||||
|
||||
e2d::Sprite::Sprite(const String& filePath, double x, double y, double width, double height)
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
open(filePath);
|
||||
crop(x, y, width, height);
|
||||
}
|
||||
|
||||
e2d::Sprite::Sprite(int resNameId, const String& resType, double x, double y, double width, double height)
|
||||
: m_pImage(nullptr)
|
||||
: _pImage(nullptr)
|
||||
{
|
||||
open(resNameId, resType);
|
||||
crop(x, y, width, height);
|
||||
|
|
@ -46,11 +46,11 @@ bool e2d::Sprite::open(Image * image)
|
|||
{
|
||||
if (image)
|
||||
{
|
||||
SafeRelease(&m_pImage);
|
||||
m_pImage = image;
|
||||
m_pImage->retain();
|
||||
SafeRelease(&_pImage);
|
||||
_pImage = image;
|
||||
_pImage->retain();
|
||||
|
||||
Node::setSize(m_pImage->getWidth(), m_pImage->getHeight());
|
||||
Node::setSize(_pImage->getWidth(), _pImage->getHeight());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -58,15 +58,15 @@ bool e2d::Sprite::open(Image * image)
|
|||
|
||||
bool e2d::Sprite::open(const String& filePath)
|
||||
{
|
||||
if (!m_pImage)
|
||||
if (!_pImage)
|
||||
{
|
||||
m_pImage = new (std::nothrow) Image();
|
||||
m_pImage->retain();
|
||||
_pImage = new (std::nothrow) Image();
|
||||
_pImage->retain();
|
||||
}
|
||||
|
||||
if (m_pImage->open(filePath))
|
||||
if (_pImage->open(filePath))
|
||||
{
|
||||
Node::setSize(m_pImage->getWidth(), m_pImage->getHeight());
|
||||
Node::setSize(_pImage->getWidth(), _pImage->getHeight());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -74,15 +74,15 @@ bool e2d::Sprite::open(const String& filePath)
|
|||
|
||||
bool e2d::Sprite::open(int resNameId, const String& resType)
|
||||
{
|
||||
if (!m_pImage)
|
||||
if (!_pImage)
|
||||
{
|
||||
m_pImage = new (std::nothrow) Image();
|
||||
m_pImage->retain();
|
||||
_pImage = new (std::nothrow) Image();
|
||||
_pImage->retain();
|
||||
}
|
||||
|
||||
if (m_pImage->open(resNameId, resType))
|
||||
if (_pImage->open(resNameId, resType))
|
||||
{
|
||||
Node::setSize(m_pImage->getWidth(), m_pImage->getHeight());
|
||||
Node::setSize(_pImage->getWidth(), _pImage->getHeight());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -90,36 +90,36 @@ bool e2d::Sprite::open(int resNameId, const String& resType)
|
|||
|
||||
void e2d::Sprite::crop(double x, double y, double width, double height)
|
||||
{
|
||||
m_pImage->crop(x, y, width, height);
|
||||
_pImage->crop(x, y, width, height);
|
||||
Node::setSize(
|
||||
min(max(width, 0), m_pImage->getSourceWidth() - m_pImage->getCropX()),
|
||||
min(max(height, 0), m_pImage->getSourceHeight() - m_pImage->getCropY())
|
||||
min(max(width, 0), _pImage->getSourceWidth() - _pImage->getCropX()),
|
||||
min(max(height, 0), _pImage->getSourceHeight() - _pImage->getCropY())
|
||||
);
|
||||
}
|
||||
|
||||
e2d::Image * e2d::Sprite::getImage() const
|
||||
{
|
||||
return m_pImage;
|
||||
return _pImage;
|
||||
}
|
||||
|
||||
void e2d::Sprite::onRender()
|
||||
{
|
||||
if (m_pImage && m_pImage->getBitmap())
|
||||
if (_pImage && _pImage->getBitmap())
|
||||
{
|
||||
// »ñȡͼƬ²Ã¼ôλÖÃ
|
||||
float fCropX = static_cast<float>(m_pImage->getCropX());
|
||||
float fCropY = static_cast<float>(m_pImage->getCropY());
|
||||
float fCropX = static_cast<float>(_pImage->getCropX());
|
||||
float fCropY = static_cast<float>(_pImage->getCropY());
|
||||
// äÖȾͼƬ
|
||||
Renderer::getRenderTarget()->DrawBitmap(
|
||||
m_pImage->getBitmap(),
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
m_fDisplayOpacity,
|
||||
_pImage->getBitmap(),
|
||||
D2D1::RectF(0, 0, _fWidth, _fHeight),
|
||||
_fDisplayOpacity,
|
||||
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
|
||||
D2D1::RectF(
|
||||
fCropX,
|
||||
fCropY,
|
||||
fCropX + m_fWidth,
|
||||
fCropY + m_fHeight
|
||||
fCropX + _fWidth,
|
||||
fCropY + _fHeight
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -128,5 +128,5 @@ void e2d::Sprite::onRender()
|
|||
void e2d::Sprite::destroy()
|
||||
{
|
||||
Node::destroy();
|
||||
SafeRelease(&m_pImage);
|
||||
SafeRelease(&_pImage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,34 +2,34 @@
|
|||
|
||||
|
||||
e2d::Text::Text()
|
||||
: m_TextStyle()
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
: _TextStyle()
|
||||
, _pDWriteTextLayout(nullptr)
|
||||
, _pDWriteTextFormat(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Text::Text(const String& text)
|
||||
: m_TextStyle()
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
: _TextStyle()
|
||||
, _pDWriteTextLayout(nullptr)
|
||||
, _pDWriteTextFormat(nullptr)
|
||||
, _sText(text)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
||||
e2d::Text::Text(TextStyle textStyle)
|
||||
: m_TextStyle(textStyle)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
: _TextStyle(textStyle)
|
||||
, _pDWriteTextLayout(nullptr)
|
||||
, _pDWriteTextFormat(nullptr)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
||||
e2d::Text::Text(const String& text, TextStyle textStyle)
|
||||
: m_TextStyle(textStyle)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
: _TextStyle(textStyle)
|
||||
, _pDWriteTextLayout(nullptr)
|
||||
, _pDWriteTextFormat(nullptr)
|
||||
, _sText(text)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ e2d::Text::Text(
|
|||
UINT32 outlineColor,
|
||||
UINT32 outlineWidth
|
||||
)
|
||||
: m_TextStyle(
|
||||
: _TextStyle(
|
||||
fontFamily,
|
||||
fontSize,
|
||||
color,
|
||||
|
|
@ -67,70 +67,70 @@ e2d::Text::Text(
|
|||
outlineColor,
|
||||
outlineWidth
|
||||
)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
, _pDWriteTextLayout(nullptr)
|
||||
, _pDWriteTextFormat(nullptr)
|
||||
, _sText(text)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
||||
e2d::Text::~Text()
|
||||
{
|
||||
SafeReleaseInterface(&m_pDWriteTextFormat);
|
||||
SafeReleaseInterface(&m_pDWriteTextLayout);
|
||||
SafeReleaseInterface(&_pDWriteTextFormat);
|
||||
SafeReleaseInterface(&_pDWriteTextLayout);
|
||||
}
|
||||
|
||||
e2d::String e2d::Text::getText() const
|
||||
{
|
||||
return m_sText;
|
||||
return _sText;
|
||||
}
|
||||
|
||||
e2d::TextStyle e2d::Text::getTextStyle() const
|
||||
{
|
||||
return m_TextStyle;
|
||||
return _TextStyle;
|
||||
}
|
||||
|
||||
e2d::String e2d::Text::getFontFamily() const
|
||||
{
|
||||
return m_TextStyle.fontFamily;
|
||||
return _TextStyle.fontFamily;
|
||||
}
|
||||
|
||||
double e2d::Text::getFontSize() const
|
||||
{
|
||||
return m_TextStyle.fontSize;
|
||||
return _TextStyle.fontSize;
|
||||
}
|
||||
|
||||
UINT32 e2d::Text::getFontWeight() const
|
||||
{
|
||||
return m_TextStyle.fontWeight;
|
||||
return _TextStyle.fontWeight;
|
||||
}
|
||||
|
||||
e2d::Color e2d::Text::getColor() const
|
||||
{
|
||||
return m_TextStyle.color;
|
||||
return _TextStyle.color;
|
||||
}
|
||||
|
||||
e2d::Color e2d::Text::getOutlineColor() const
|
||||
{
|
||||
return m_TextStyle.outlineColor;
|
||||
return _TextStyle.outlineColor;
|
||||
}
|
||||
|
||||
double e2d::Text::getOutlineWidth() const
|
||||
{
|
||||
return m_TextStyle.outlineWidth;
|
||||
return _TextStyle.outlineWidth;
|
||||
}
|
||||
|
||||
e2d::LineJoin e2d::Text::getOutlineJoin() const
|
||||
{
|
||||
return m_TextStyle.outlineJoin;
|
||||
return _TextStyle.outlineJoin;
|
||||
}
|
||||
|
||||
int e2d::Text::getLineCount() const
|
||||
{
|
||||
if (m_pDWriteTextLayout)
|
||||
if (_pDWriteTextLayout)
|
||||
{
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
m_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
return static_cast<int>(metrics.lineCount);
|
||||
}
|
||||
else
|
||||
|
|
@ -141,81 +141,81 @@ int e2d::Text::getLineCount() const
|
|||
|
||||
bool e2d::Text::isItalic() const
|
||||
{
|
||||
return m_TextStyle.italic;
|
||||
return _TextStyle.italic;
|
||||
}
|
||||
|
||||
bool e2d::Text::hasStrikethrough() const
|
||||
{
|
||||
return m_TextStyle.hasStrikethrough;
|
||||
return _TextStyle.hasStrikethrough;
|
||||
}
|
||||
|
||||
bool e2d::Text::hasUnderline() const
|
||||
{
|
||||
return m_TextStyle.hasUnderline;
|
||||
return _TextStyle.hasUnderline;
|
||||
}
|
||||
|
||||
bool e2d::Text::hasOutline() const
|
||||
{
|
||||
return m_TextStyle.hasOutline;
|
||||
return _TextStyle.hasOutline;
|
||||
}
|
||||
|
||||
void e2d::Text::setText(const String& text)
|
||||
{
|
||||
m_sText = text;
|
||||
_sText = text;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setTextStyle(TextStyle textStyle)
|
||||
{
|
||||
m_TextStyle = textStyle;
|
||||
_TextStyle = textStyle;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setFontFamily(const String& fontFamily)
|
||||
{
|
||||
m_TextStyle.fontFamily = fontFamily;
|
||||
_TextStyle.fontFamily = fontFamily;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setFontSize(double fontSize)
|
||||
{
|
||||
m_TextStyle.fontSize = fontSize;
|
||||
_TextStyle.fontSize = fontSize;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setFontWeight(UINT32 fontWeight)
|
||||
{
|
||||
m_TextStyle.fontWeight = fontWeight;
|
||||
_TextStyle.fontWeight = fontWeight;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setColor(Color color)
|
||||
{
|
||||
m_TextStyle.color = color;
|
||||
_TextStyle.color = color;
|
||||
}
|
||||
|
||||
void e2d::Text::setItalic(bool value)
|
||||
{
|
||||
m_TextStyle.italic = value;
|
||||
_TextStyle.italic = value;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setWrapping(bool wrapping)
|
||||
{
|
||||
if (m_TextStyle.wrapping != wrapping)
|
||||
if (_TextStyle.wrapping != wrapping)
|
||||
{
|
||||
m_TextStyle.wrapping = wrapping;
|
||||
_TextStyle.wrapping = wrapping;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setWrappingWidth(double fWrappingWidth)
|
||||
{
|
||||
if (m_TextStyle.wrappingWidth != fWrappingWidth)
|
||||
if (_TextStyle.wrappingWidth != fWrappingWidth)
|
||||
{
|
||||
m_TextStyle.wrappingWidth = max(fWrappingWidth, 0);
|
||||
_TextStyle.wrappingWidth = max(fWrappingWidth, 0);
|
||||
|
||||
if (m_TextStyle.wrapping)
|
||||
if (_TextStyle.wrapping)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
|
@ -224,28 +224,28 @@ void e2d::Text::setWrappingWidth(double fWrappingWidth)
|
|||
|
||||
void e2d::Text::setLineSpacing(double fLineSpacing)
|
||||
{
|
||||
if (m_TextStyle.lineSpacing != fLineSpacing)
|
||||
if (_TextStyle.lineSpacing != fLineSpacing)
|
||||
{
|
||||
m_TextStyle.lineSpacing = fLineSpacing;
|
||||
_TextStyle.lineSpacing = fLineSpacing;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setAlignment(TextAlign align)
|
||||
{
|
||||
if (m_TextStyle.alignment != align)
|
||||
if (_TextStyle.alignment != align)
|
||||
{
|
||||
m_TextStyle.alignment = align;
|
||||
_TextStyle.alignment = align;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setUnderline(bool hasUnderline)
|
||||
{
|
||||
if (m_TextStyle.hasUnderline != hasUnderline)
|
||||
if (_TextStyle.hasUnderline != hasUnderline)
|
||||
{
|
||||
m_TextStyle.hasUnderline = hasUnderline;
|
||||
if (!m_pDWriteTextFormat)
|
||||
_TextStyle.hasUnderline = hasUnderline;
|
||||
if (!_pDWriteTextFormat)
|
||||
_createFormat();
|
||||
_createLayout();
|
||||
}
|
||||
|
|
@ -253,10 +253,10 @@ void e2d::Text::setUnderline(bool hasUnderline)
|
|||
|
||||
void e2d::Text::setStrikethrough(bool hasStrikethrough)
|
||||
{
|
||||
if (m_TextStyle.hasStrikethrough != hasStrikethrough)
|
||||
if (_TextStyle.hasStrikethrough != hasStrikethrough)
|
||||
{
|
||||
m_TextStyle.hasStrikethrough = hasStrikethrough;
|
||||
if (!m_pDWriteTextFormat)
|
||||
_TextStyle.hasStrikethrough = hasStrikethrough;
|
||||
if (!_pDWriteTextFormat)
|
||||
_createFormat();
|
||||
_createLayout();
|
||||
}
|
||||
|
|
@ -264,42 +264,42 @@ void e2d::Text::setStrikethrough(bool hasStrikethrough)
|
|||
|
||||
void e2d::Text::setOutline(bool hasOutline)
|
||||
{
|
||||
m_TextStyle.hasOutline = hasOutline;
|
||||
_TextStyle.hasOutline = hasOutline;
|
||||
}
|
||||
|
||||
void e2d::Text::setOutlineColor(Color outlineColor)
|
||||
{
|
||||
m_TextStyle.outlineColor = outlineColor;
|
||||
_TextStyle.outlineColor = outlineColor;
|
||||
}
|
||||
|
||||
void e2d::Text::setOutlineWidth(double outlineWidth)
|
||||
{
|
||||
m_TextStyle.outlineWidth = outlineWidth;
|
||||
_TextStyle.outlineWidth = outlineWidth;
|
||||
}
|
||||
|
||||
void e2d::Text::setOutlineJoin(LineJoin outlineJoin)
|
||||
{
|
||||
m_TextStyle.outlineJoin = outlineJoin;
|
||||
_TextStyle.outlineJoin = outlineJoin;
|
||||
}
|
||||
|
||||
void e2d::Text::onRender()
|
||||
{
|
||||
if (m_pDWriteTextLayout)
|
||||
if (_pDWriteTextLayout)
|
||||
{
|
||||
// 创建文本区域
|
||||
D2D1_RECT_F textLayoutRect = D2D1::RectF(0, 0, m_fWidth, m_fHeight);
|
||||
D2D1_RECT_F textLayoutRect = D2D1::RectF(0, 0, _fWidth, _fHeight);
|
||||
// 设置画刷颜色和透明度
|
||||
Renderer::getSolidColorBrush()->SetOpacity(m_fDisplayOpacity);
|
||||
Renderer::getSolidColorBrush()->SetOpacity(_fDisplayOpacity);
|
||||
// 获取文本渲染器
|
||||
auto pTextRenderer = Renderer::getCustomTextRenderer();
|
||||
pTextRenderer->SetTextStyle(
|
||||
m_TextStyle.color.toColorF(),
|
||||
m_TextStyle.hasOutline,
|
||||
m_TextStyle.outlineColor.toColorF(),
|
||||
static_cast<FLOAT>(m_TextStyle.outlineWidth),
|
||||
D2D1_LINE_JOIN(m_TextStyle.outlineJoin)
|
||||
_TextStyle.color.toColorF(),
|
||||
_TextStyle.hasOutline,
|
||||
_TextStyle.outlineColor.toColorF(),
|
||||
static_cast<FLOAT>(_TextStyle.outlineWidth),
|
||||
D2D1_LINE_JOIN(_TextStyle.outlineJoin)
|
||||
);
|
||||
m_pDWriteTextLayout->Draw(NULL, pTextRenderer, 0, 0);
|
||||
_pDWriteTextLayout->Draw(NULL, pTextRenderer, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,105 +313,105 @@ void e2d::Text::_reset()
|
|||
|
||||
void e2d::Text::_createFormat()
|
||||
{
|
||||
SafeReleaseInterface(&m_pDWriteTextFormat);
|
||||
SafeReleaseInterface(&_pDWriteTextFormat);
|
||||
|
||||
HRESULT hr = Renderer::getIDWriteFactory()->CreateTextFormat(
|
||||
m_TextStyle.fontFamily,
|
||||
_TextStyle.fontFamily,
|
||||
NULL,
|
||||
DWRITE_FONT_WEIGHT(m_TextStyle.fontWeight),
|
||||
m_TextStyle.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_WEIGHT(_TextStyle.fontWeight),
|
||||
_TextStyle.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL,
|
||||
static_cast<float>(m_TextStyle.fontSize),
|
||||
static_cast<float>(_TextStyle.fontSize),
|
||||
L"",
|
||||
&m_pDWriteTextFormat
|
||||
&_pDWriteTextFormat
|
||||
);
|
||||
|
||||
ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!");
|
||||
|
||||
if (m_pDWriteTextFormat)
|
||||
if (_pDWriteTextFormat)
|
||||
{
|
||||
// 设置文字对齐方式
|
||||
m_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(m_TextStyle.alignment));
|
||||
_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(_TextStyle.alignment));
|
||||
// 设置行间距
|
||||
if (m_TextStyle.lineSpacing == 0.0)
|
||||
if (_TextStyle.lineSpacing == 0.0)
|
||||
{
|
||||
m_pDWriteTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0);
|
||||
_pDWriteTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pDWriteTextFormat->SetLineSpacing(
|
||||
_pDWriteTextFormat->SetLineSpacing(
|
||||
DWRITE_LINE_SPACING_METHOD_UNIFORM,
|
||||
static_cast<FLOAT>(m_TextStyle.lineSpacing),
|
||||
static_cast<FLOAT>(m_TextStyle.lineSpacing) * 0.8f
|
||||
static_cast<FLOAT>(_TextStyle.lineSpacing),
|
||||
static_cast<FLOAT>(_TextStyle.lineSpacing) * 0.8f
|
||||
);
|
||||
}
|
||||
// 打开文本自动换行时,设置换行属性
|
||||
if (m_TextStyle.wrapping)
|
||||
if (_TextStyle.wrapping)
|
||||
{
|
||||
m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
|
||||
_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||
_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::_createLayout()
|
||||
{
|
||||
SafeReleaseInterface(&m_pDWriteTextLayout);
|
||||
SafeReleaseInterface(&_pDWriteTextLayout);
|
||||
|
||||
// 文本为空字符串时,重置属性
|
||||
if (m_sText.isEmpty())
|
||||
if (_sText.isEmpty())
|
||||
{
|
||||
this->setSize(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pDWriteTextFormat == nullptr)
|
||||
if (_pDWriteTextFormat == nullptr)
|
||||
{
|
||||
WARN_IF(true, "Text::_createLayout failed! m_pDWriteTextFormat NULL pointer exception.");
|
||||
WARN_IF(true, "Text::_createLayout failed! _pDWriteTextFormat NULL pointer exception.");
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 length = static_cast<UINT32>(m_sText.getLength());
|
||||
UINT32 length = static_cast<UINT32>(_sText.getLength());
|
||||
|
||||
// 创建 TextLayout
|
||||
HRESULT hr;
|
||||
// 对文本自动换行情况下进行处理
|
||||
if (m_TextStyle.wrapping)
|
||||
if (_TextStyle.wrapping)
|
||||
{
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(
|
||||
m_sText,
|
||||
_sText,
|
||||
length,
|
||||
m_pDWriteTextFormat,
|
||||
static_cast<FLOAT>(m_TextStyle.wrappingWidth),
|
||||
_pDWriteTextFormat,
|
||||
static_cast<FLOAT>(_TextStyle.wrappingWidth),
|
||||
0,
|
||||
&m_pDWriteTextLayout
|
||||
&_pDWriteTextLayout
|
||||
);
|
||||
if (m_pDWriteTextLayout)
|
||||
if (_pDWriteTextLayout)
|
||||
{
|
||||
// 获取文本布局的宽度和高度
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
m_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
// 重设文本宽高
|
||||
this->setSize(metrics.layoutWidth, metrics.height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(m_sText, length, m_pDWriteTextFormat, 0, 0, &m_pDWriteTextLayout);
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(_sText, length, _pDWriteTextFormat, 0, 0, &_pDWriteTextLayout);
|
||||
// 为防止文本对齐问题,根据刚才创建的 layout 宽度重新创建它
|
||||
if (m_pDWriteTextLayout)
|
||||
if (_pDWriteTextLayout)
|
||||
{
|
||||
// 获取文本布局的宽度和高度
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
m_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
_pDWriteTextLayout->GetMetrics(&metrics);
|
||||
// 重设文本宽高
|
||||
this->setSize(metrics.width, metrics.height);
|
||||
// 重新创建 layout
|
||||
SafeReleaseInterface(&m_pDWriteTextLayout);
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(m_sText, length, m_pDWriteTextFormat, m_fWidth, 0, &m_pDWriteTextLayout);
|
||||
SafeReleaseInterface(&_pDWriteTextLayout);
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(_sText, length, _pDWriteTextFormat, _fWidth, 0, &_pDWriteTextLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,12 +419,12 @@ void e2d::Text::_createLayout()
|
|||
|
||||
// 添加下划线和删除线
|
||||
DWRITE_TEXT_RANGE range = { 0, length };
|
||||
if (m_TextStyle.hasUnderline)
|
||||
if (_TextStyle.hasUnderline)
|
||||
{
|
||||
m_pDWriteTextLayout->SetUnderline(true, range);
|
||||
_pDWriteTextLayout->SetUnderline(true, range);
|
||||
}
|
||||
if (m_TextStyle.hasStrikethrough)
|
||||
if (_TextStyle.hasStrikethrough)
|
||||
{
|
||||
m_pDWriteTextLayout->SetStrikethrough(true, range);
|
||||
_pDWriteTextLayout->SetStrikethrough(true, range);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,16 +79,16 @@ protected:
|
|||
);
|
||||
|
||||
protected:
|
||||
bool m_bOpened;
|
||||
mutable bool m_bPlaying;
|
||||
DWORD m_dwSize;
|
||||
CHAR* m_pResourceBuffer;
|
||||
BYTE* m_pbWaveData;
|
||||
HMMIO m_hmmio;
|
||||
MMCKINFO m_ck;
|
||||
MMCKINFO m_ckRiff;
|
||||
WAVEFORMATEX* m_pwfx;
|
||||
IXAudio2SourceVoice* m_pSourceVoice;
|
||||
bool _bOpened;
|
||||
mutable bool _bPlaying;
|
||||
DWORD _dwSize;
|
||||
CHAR* _pResourceBuffer;
|
||||
BYTE* _pbWaveData;
|
||||
HMMIO _hmmio;
|
||||
MMCKINFO _ck;
|
||||
MMCKINFO _ckRiff;
|
||||
WAVEFORMATEX* _pwfx;
|
||||
IXAudio2SourceVoice* _pSourceVoice;
|
||||
};
|
||||
|
||||
typedef std::map<UINT, MusicPlayer *> MusicMap;
|
||||
|
|
@ -106,14 +106,14 @@ static MusicMap& GetMusicResList()
|
|||
}
|
||||
|
||||
MusicPlayer::MusicPlayer()
|
||||
: m_bOpened(false)
|
||||
, m_bPlaying(false)
|
||||
, m_pwfx(nullptr)
|
||||
, m_hmmio(nullptr)
|
||||
, m_pResourceBuffer(nullptr)
|
||||
, m_pbWaveData(nullptr)
|
||||
, m_dwSize(0)
|
||||
, m_pSourceVoice(nullptr)
|
||||
: _bOpened(false)
|
||||
, _bPlaying(false)
|
||||
, _pwfx(nullptr)
|
||||
, _hmmio(nullptr)
|
||||
, _pResourceBuffer(nullptr)
|
||||
, _pbWaveData(nullptr)
|
||||
, _dwSize(0)
|
||||
, _pSourceVoice(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ MusicPlayer::~MusicPlayer()
|
|||
|
||||
bool MusicPlayer::open(const e2d::String& filePath)
|
||||
{
|
||||
if (m_bOpened)
|
||||
if (_bOpened)
|
||||
{
|
||||
WARN_IF(true, "MusicInfo can be opened only once!");
|
||||
return false;
|
||||
|
|
@ -150,9 +150,9 @@ bool MusicPlayer::open(const e2d::String& filePath)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_hmmio = mmioOpen(pFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ);
|
||||
_hmmio = mmioOpen(pFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ);
|
||||
|
||||
if (nullptr == m_hmmio)
|
||||
if (nullptr == _hmmio)
|
||||
{
|
||||
return TraceError(L"mmioOpen");
|
||||
}
|
||||
|
|
@ -160,37 +160,37 @@ bool MusicPlayer::open(const e2d::String& filePath)
|
|||
if (!_readMMIO())
|
||||
{
|
||||
// 读取非 wave 文件时 ReadMMIO 调用失败
|
||||
mmioClose(m_hmmio, 0);
|
||||
mmioClose(_hmmio, 0);
|
||||
return TraceError(L"_readMMIO");
|
||||
}
|
||||
|
||||
if (!_resetFile())
|
||||
return TraceError(L"_resetFile");
|
||||
|
||||
// 重置文件后,wave 文件的大小是 m_ck.cksize
|
||||
m_dwSize = m_ck.cksize;
|
||||
// 重置文件后,wave 文件的大小是 _ck.cksize
|
||||
_dwSize = _ck.cksize;
|
||||
|
||||
// 将样本数据读取到内存中
|
||||
m_pbWaveData = new BYTE[m_dwSize];
|
||||
_pbWaveData = new BYTE[_dwSize];
|
||||
|
||||
if (!_read(m_pbWaveData, m_dwSize))
|
||||
if (!_read(_pbWaveData, _dwSize))
|
||||
{
|
||||
TraceError(L"Failed to read WAV data");
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 创建音源
|
||||
HRESULT hr;
|
||||
if (FAILED(hr = s_pXAudio2->CreateSourceVoice(&m_pSourceVoice, m_pwfx)))
|
||||
if (FAILED(hr = s_pXAudio2->CreateSourceVoice(&_pSourceVoice, _pwfx)))
|
||||
{
|
||||
TraceError(L"Create source voice error", hr);
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bOpened = true;
|
||||
m_bPlaying = false;
|
||||
_bOpened = true;
|
||||
_bPlaying = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ bool MusicPlayer::open(int resNameId, const e2d::String& resType)
|
|||
DWORD dwSize;
|
||||
void* pvRes;
|
||||
|
||||
if (m_bOpened)
|
||||
if (_bOpened)
|
||||
{
|
||||
WARN_IF(true, "MusicInfo can be opened only once!");
|
||||
return false;
|
||||
|
|
@ -226,69 +226,69 @@ bool MusicPlayer::open(int resNameId, const e2d::String& resType)
|
|||
if (nullptr == (pvRes = LockResource(hResData)))
|
||||
return TraceError(L"LockResource");
|
||||
|
||||
m_pResourceBuffer = new CHAR[dwSize];
|
||||
memcpy(m_pResourceBuffer, pvRes, dwSize);
|
||||
_pResourceBuffer = new CHAR[dwSize];
|
||||
memcpy(_pResourceBuffer, pvRes, dwSize);
|
||||
|
||||
MMIOINFO mmioInfo;
|
||||
ZeroMemory(&mmioInfo, sizeof(mmioInfo));
|
||||
mmioInfo.fccIOProc = FOURCC_MEM;
|
||||
mmioInfo.cchBuffer = dwSize;
|
||||
mmioInfo.pchBuffer = (CHAR*)m_pResourceBuffer;
|
||||
mmioInfo.pchBuffer = (CHAR*)_pResourceBuffer;
|
||||
|
||||
m_hmmio = mmioOpen(nullptr, &mmioInfo, MMIO_ALLOCBUF | MMIO_READ);
|
||||
_hmmio = mmioOpen(nullptr, &mmioInfo, MMIO_ALLOCBUF | MMIO_READ);
|
||||
|
||||
if (!_readMMIO())
|
||||
{
|
||||
// ReadMMIO will fail if its an not a wave file
|
||||
mmioClose(m_hmmio, 0);
|
||||
mmioClose(_hmmio, 0);
|
||||
return TraceError(L"ReadMMIO");
|
||||
}
|
||||
|
||||
if (!_resetFile())
|
||||
return TraceError(L"ResetFile");
|
||||
|
||||
// After the reset, the size of the wav file is m_ck.cksize so store it now
|
||||
m_dwSize = m_ck.cksize;
|
||||
// After the reset, the size of the wav file is _ck.cksize so store it now
|
||||
_dwSize = _ck.cksize;
|
||||
|
||||
// Read the sample data into memory
|
||||
m_pbWaveData = new BYTE[m_dwSize];
|
||||
_pbWaveData = new BYTE[_dwSize];
|
||||
|
||||
if (!_read(m_pbWaveData, m_dwSize))
|
||||
if (!_read(_pbWaveData, _dwSize))
|
||||
{
|
||||
TraceError(L"Failed to read WAV data");
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 创建音源
|
||||
HRESULT hr;
|
||||
if (FAILED(hr = s_pXAudio2->CreateSourceVoice(&m_pSourceVoice, m_pwfx)))
|
||||
if (FAILED(hr = s_pXAudio2->CreateSourceVoice(&_pSourceVoice, _pwfx)))
|
||||
{
|
||||
TraceError(L"Create source voice error", hr);
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bOpened = true;
|
||||
m_bPlaying = false;
|
||||
_bOpened = true;
|
||||
_bPlaying = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MusicPlayer::play(int nLoopCount)
|
||||
{
|
||||
if (!m_bOpened)
|
||||
if (!_bOpened)
|
||||
{
|
||||
WARN_IF(true, "MusicInfo::play Failed: MusicInfo must be opened first!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_pSourceVoice == nullptr)
|
||||
if (_pSourceVoice == nullptr)
|
||||
{
|
||||
WARN_IF(true, "MusicInfo::play Failed: IXAudio2SourceVoice Null pointer exception!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_bPlaying)
|
||||
if (_bPlaying)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
|
@ -298,23 +298,23 @@ bool MusicPlayer::play(int nLoopCount)
|
|||
|
||||
// 提交 wave 样本数据
|
||||
XAUDIO2_BUFFER buffer = { 0 };
|
||||
buffer.pAudioData = m_pbWaveData;
|
||||
buffer.pAudioData = _pbWaveData;
|
||||
buffer.Flags = XAUDIO2_END_OF_STREAM;
|
||||
buffer.AudioBytes = m_dwSize;
|
||||
buffer.AudioBytes = _dwSize;
|
||||
buffer.LoopCount = nLoopCount;
|
||||
|
||||
HRESULT hr;
|
||||
if (FAILED(hr = m_pSourceVoice->SubmitSourceBuffer(&buffer)))
|
||||
if (FAILED(hr = _pSourceVoice->SubmitSourceBuffer(&buffer)))
|
||||
{
|
||||
TraceError(L"Submitting source buffer error", hr);
|
||||
m_pSourceVoice->DestroyVoice();
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
_pSourceVoice->DestroyVoice();
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr = m_pSourceVoice->Start(0)))
|
||||
if (SUCCEEDED(hr = _pSourceVoice->Start(0)))
|
||||
{
|
||||
m_bPlaying = true;
|
||||
_bPlaying = true;
|
||||
}
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
|
|
@ -322,75 +322,75 @@ bool MusicPlayer::play(int nLoopCount)
|
|||
|
||||
void MusicPlayer::pause()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
if (_pSourceVoice)
|
||||
{
|
||||
if (SUCCEEDED(m_pSourceVoice->Stop()))
|
||||
if (SUCCEEDED(_pSourceVoice->Stop()))
|
||||
{
|
||||
m_bPlaying = false;
|
||||
_bPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::resume()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
if (_pSourceVoice)
|
||||
{
|
||||
if (SUCCEEDED(m_pSourceVoice->Start()))
|
||||
if (SUCCEEDED(_pSourceVoice->Start()))
|
||||
{
|
||||
m_bPlaying = true;
|
||||
_bPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::stop()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
if (_pSourceVoice)
|
||||
{
|
||||
if (SUCCEEDED(m_pSourceVoice->Stop()))
|
||||
if (SUCCEEDED(_pSourceVoice->Stop()))
|
||||
{
|
||||
m_pSourceVoice->ExitLoop();
|
||||
m_pSourceVoice->FlushSourceBuffers();
|
||||
m_bPlaying = false;
|
||||
_pSourceVoice->ExitLoop();
|
||||
_pSourceVoice->FlushSourceBuffers();
|
||||
_bPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::close()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
if (_pSourceVoice)
|
||||
{
|
||||
m_pSourceVoice->Stop();
|
||||
m_pSourceVoice->FlushSourceBuffers();
|
||||
m_pSourceVoice->DestroyVoice();
|
||||
m_pSourceVoice = nullptr;
|
||||
_pSourceVoice->Stop();
|
||||
_pSourceVoice->FlushSourceBuffers();
|
||||
_pSourceVoice->DestroyVoice();
|
||||
_pSourceVoice = nullptr;
|
||||
}
|
||||
|
||||
if (m_hmmio != nullptr)
|
||||
if (_hmmio != nullptr)
|
||||
{
|
||||
mmioClose(m_hmmio, 0);
|
||||
m_hmmio = nullptr;
|
||||
mmioClose(_hmmio, 0);
|
||||
_hmmio = nullptr;
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(m_pResourceBuffer);
|
||||
SAFE_DELETE_ARRAY(m_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(m_pwfx);
|
||||
SAFE_DELETE_ARRAY(_pResourceBuffer);
|
||||
SAFE_DELETE_ARRAY(_pbWaveData);
|
||||
SAFE_DELETE_ARRAY(_pwfx);
|
||||
|
||||
m_bOpened = false;
|
||||
m_bPlaying = false;
|
||||
_bOpened = false;
|
||||
_bPlaying = false;
|
||||
}
|
||||
|
||||
bool MusicPlayer::isPlaying() const
|
||||
{
|
||||
if (m_bOpened && m_pSourceVoice)
|
||||
if (_bOpened && _pSourceVoice)
|
||||
{
|
||||
XAUDIO2_VOICE_STATE state;
|
||||
m_pSourceVoice->GetState(&state);
|
||||
_pSourceVoice->GetState(&state);
|
||||
|
||||
if (state.BuffersQueued == 0)
|
||||
{
|
||||
m_bPlaying = false;
|
||||
_bPlaying = false;
|
||||
}
|
||||
return m_bPlaying;
|
||||
return _bPlaying;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -400,9 +400,9 @@ bool MusicPlayer::isPlaying() const
|
|||
|
||||
bool MusicPlayer::setVolume(float fVolume)
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
if (_pSourceVoice)
|
||||
{
|
||||
return SUCCEEDED(m_pSourceVoice->SetVolume(fVolume));
|
||||
return SUCCEEDED(_pSourceVoice->SetVolume(fVolume));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -414,19 +414,19 @@ bool MusicPlayer::_readMMIO()
|
|||
|
||||
memset(&ckIn, 0, sizeof(ckIn));
|
||||
|
||||
m_pwfx = nullptr;
|
||||
_pwfx = nullptr;
|
||||
|
||||
if ((0 != mmioDescend(m_hmmio, &m_ckRiff, nullptr, 0)))
|
||||
if ((0 != mmioDescend(_hmmio, &_ckRiff, nullptr, 0)))
|
||||
return TraceError(L"mmioDescend");
|
||||
|
||||
// 确认文件是一个合法的 wave 文件
|
||||
if ((m_ckRiff.ckid != FOURCC_RIFF) ||
|
||||
(m_ckRiff.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
|
||||
if ((_ckRiff.ckid != FOURCC_RIFF) ||
|
||||
(_ckRiff.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
|
||||
return TraceError(L"mmioFOURCC");
|
||||
|
||||
// 在输入文件中查找 'fmt' 块
|
||||
ckIn.ckid = mmioFOURCC('f', 'm', 't', ' ');
|
||||
if (0 != mmioDescend(m_hmmio, &ckIn, &m_ckRiff, MMIO_FINDCHUNK))
|
||||
if (0 != mmioDescend(_hmmio, &ckIn, &_ckRiff, MMIO_FINDCHUNK))
|
||||
return TraceError(L"mmioDescend");
|
||||
|
||||
// 'fmt' 块至少应和 PCMWAVEFORMAT 一样大
|
||||
|
|
@ -434,7 +434,7 @@ bool MusicPlayer::_readMMIO()
|
|||
return TraceError(L"sizeof(PCMWAVEFORMAT)");
|
||||
|
||||
// 将 'fmt' 块读取到 pcmWaveFormat 中
|
||||
if (mmioRead(m_hmmio, (HPSTR)&pcmWaveFormat,
|
||||
if (mmioRead(_hmmio, (HPSTR)&pcmWaveFormat,
|
||||
sizeof(pcmWaveFormat)) != sizeof(pcmWaveFormat))
|
||||
return TraceError(L"mmioRead");
|
||||
|
||||
|
|
@ -442,37 +442,37 @@ bool MusicPlayer::_readMMIO()
|
|||
// 的数据,这个数据就是额外分配的大小
|
||||
if (pcmWaveFormat.wf.wFormatTag == WAVE_FORMAT_PCM)
|
||||
{
|
||||
m_pwfx = (WAVEFORMATEX*)new CHAR[sizeof(WAVEFORMATEX)];
|
||||
_pwfx = (WAVEFORMATEX*)new CHAR[sizeof(WAVEFORMATEX)];
|
||||
|
||||
// 拷贝数据
|
||||
memcpy(m_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
|
||||
m_pwfx->cbSize = 0;
|
||||
memcpy(_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
|
||||
_pwfx->cbSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 读取额外数据的大小
|
||||
WORD cbExtraBytes = 0L;
|
||||
if (mmioRead(m_hmmio, (CHAR*)&cbExtraBytes, sizeof(WORD)) != sizeof(WORD))
|
||||
if (mmioRead(_hmmio, (CHAR*)&cbExtraBytes, sizeof(WORD)) != sizeof(WORD))
|
||||
return TraceError(L"mmioRead");
|
||||
|
||||
m_pwfx = (WAVEFORMATEX*)new CHAR[sizeof(WAVEFORMATEX) + cbExtraBytes];
|
||||
_pwfx = (WAVEFORMATEX*)new CHAR[sizeof(WAVEFORMATEX) + cbExtraBytes];
|
||||
|
||||
// 拷贝数据
|
||||
memcpy(m_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
|
||||
m_pwfx->cbSize = cbExtraBytes;
|
||||
memcpy(_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
|
||||
_pwfx->cbSize = cbExtraBytes;
|
||||
|
||||
// 读取额外数据
|
||||
if (mmioRead(m_hmmio, (CHAR*)(((BYTE*)&(m_pwfx->cbSize)) + sizeof(WORD)),
|
||||
if (mmioRead(_hmmio, (CHAR*)(((BYTE*)&(_pwfx->cbSize)) + sizeof(WORD)),
|
||||
cbExtraBytes) != cbExtraBytes)
|
||||
{
|
||||
SAFE_DELETE(m_pwfx);
|
||||
SAFE_DELETE(_pwfx);
|
||||
return TraceError(L"mmioRead");
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != mmioAscend(m_hmmio, &ckIn, 0))
|
||||
if (0 != mmioAscend(_hmmio, &ckIn, 0))
|
||||
{
|
||||
SAFE_DELETE(m_pwfx);
|
||||
SAFE_DELETE(_pwfx);
|
||||
return TraceError(L"mmioAscend");
|
||||
}
|
||||
|
||||
|
|
@ -482,13 +482,13 @@ bool MusicPlayer::_readMMIO()
|
|||
bool MusicPlayer::_resetFile()
|
||||
{
|
||||
// Seek to the data
|
||||
if (-1 == mmioSeek(m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC),
|
||||
if (-1 == mmioSeek(_hmmio, _ckRiff.dwDataOffset + sizeof(FOURCC),
|
||||
SEEK_SET))
|
||||
return TraceError(L"mmioSeek");
|
||||
|
||||
// Search the input file for the 'data' chunk.
|
||||
m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
|
||||
if (0 != mmioDescend(m_hmmio, &m_ck, &m_ckRiff, MMIO_FINDCHUNK))
|
||||
_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
|
||||
if (0 != mmioDescend(_hmmio, &_ck, &_ckRiff, MMIO_FINDCHUNK))
|
||||
return TraceError(L"mmioDescend");
|
||||
|
||||
return true;
|
||||
|
|
@ -496,23 +496,23 @@ bool MusicPlayer::_resetFile()
|
|||
|
||||
bool MusicPlayer::_read(BYTE* pBuffer, DWORD dwSizeToRead)
|
||||
{
|
||||
MMIOINFO mmioinfoIn; // current status of m_hmmio
|
||||
MMIOINFO mmioinfoIn; // current status of _hmmio
|
||||
|
||||
if (0 != mmioGetInfo(m_hmmio, &mmioinfoIn, 0))
|
||||
if (0 != mmioGetInfo(_hmmio, &mmioinfoIn, 0))
|
||||
return TraceError(L"mmioGetInfo");
|
||||
|
||||
UINT cbDataIn = dwSizeToRead;
|
||||
if (cbDataIn > m_ck.cksize)
|
||||
cbDataIn = m_ck.cksize;
|
||||
if (cbDataIn > _ck.cksize)
|
||||
cbDataIn = _ck.cksize;
|
||||
|
||||
m_ck.cksize -= cbDataIn;
|
||||
_ck.cksize -= cbDataIn;
|
||||
|
||||
for (DWORD cT = 0; cT < cbDataIn; cT++)
|
||||
{
|
||||
// Copy the bytes from the io to the buffer.
|
||||
if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead)
|
||||
{
|
||||
if (0 != mmioAdvance(m_hmmio, &mmioinfoIn, MMIO_READ))
|
||||
if (0 != mmioAdvance(_hmmio, &mmioinfoIn, MMIO_READ))
|
||||
return TraceError(L"mmioAdvance");
|
||||
|
||||
if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead)
|
||||
|
|
@ -524,7 +524,7 @@ bool MusicPlayer::_read(BYTE* pBuffer, DWORD dwSizeToRead)
|
|||
mmioinfoIn.pchNext++;
|
||||
}
|
||||
|
||||
if (0 != mmioSetInfo(m_hmmio, &mmioinfoIn, 0))
|
||||
if (0 != mmioSetInfo(_hmmio, &mmioinfoIn, 0))
|
||||
return TraceError(L"mmioSetInfo");
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -3,44 +3,44 @@
|
|||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::TransitionBase::TransitionBase(double duration)
|
||||
: m_bEnd(false)
|
||||
, m_fLast(0)
|
||||
, m_fRateOfProgress(0)
|
||||
, m_pPrevScene(nullptr)
|
||||
, m_pNextScene(nullptr)
|
||||
, m_pPrevLayer(nullptr)
|
||||
, m_pNextLayer(nullptr)
|
||||
, m_sPrevLayerParam()
|
||||
, m_sNextLayerParam()
|
||||
: _bEnd(false)
|
||||
, _fLast(0)
|
||||
, _fRateOfProgress(0)
|
||||
, _pPrevScene(nullptr)
|
||||
, _pNextScene(nullptr)
|
||||
, _pPrevLayer(nullptr)
|
||||
, _pNextLayer(nullptr)
|
||||
, _sPrevLayerParam()
|
||||
, _sNextLayerParam()
|
||||
{
|
||||
m_fDuration = max(duration, 0);
|
||||
_fDuration = max(duration, 0);
|
||||
}
|
||||
|
||||
e2d::TransitionBase::~TransitionBase()
|
||||
{
|
||||
SafeReleaseInterface(&m_pPrevLayer);
|
||||
SafeReleaseInterface(&m_pNextLayer);
|
||||
SafeReleaseInterface(&_pPrevLayer);
|
||||
SafeReleaseInterface(&_pNextLayer);
|
||||
}
|
||||
|
||||
bool e2d::TransitionBase::isDone()
|
||||
{
|
||||
return m_bEnd;
|
||||
return _bEnd;
|
||||
}
|
||||
|
||||
void e2d::TransitionBase::destroy()
|
||||
{
|
||||
SafeRelease(&m_pPrevScene);
|
||||
SafeRelease(&m_pNextScene);
|
||||
SafeRelease(&_pPrevScene);
|
||||
SafeRelease(&_pNextScene);
|
||||
}
|
||||
|
||||
void e2d::TransitionBase::_init(Scene * prev, Scene * next)
|
||||
{
|
||||
// 创建图层
|
||||
HRESULT hr = Renderer::getRenderTarget()->CreateLayer(&m_pNextLayer);
|
||||
HRESULT hr = Renderer::getRenderTarget()->CreateLayer(&_pNextLayer);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = Renderer::getRenderTarget()->CreateLayer(&m_pPrevLayer);
|
||||
hr = Renderer::getRenderTarget()->CreateLayer(&_pPrevLayer);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
|
|
@ -48,38 +48,38 @@ void e2d::TransitionBase::_init(Scene * prev, Scene * next)
|
|||
ASSERT(false, "Create layer failed!");
|
||||
}
|
||||
|
||||
m_fLast = Time::getTotalTime();
|
||||
m_pPrevScene = prev;
|
||||
m_pNextScene = next;
|
||||
if (m_pPrevScene) m_pPrevScene->retain();
|
||||
if (m_pNextScene) m_pNextScene->retain();
|
||||
_fLast = Time::getTotalTime();
|
||||
_pPrevScene = prev;
|
||||
_pNextScene = next;
|
||||
if (_pPrevScene) _pPrevScene->retain();
|
||||
if (_pNextScene) _pNextScene->retain();
|
||||
|
||||
m_WindowSize = Window::getSize();
|
||||
m_sPrevLayerParam = m_sNextLayerParam = D2D1::LayerParameters();
|
||||
_WindowSize = Window::getSize();
|
||||
_sPrevLayerParam = _sNextLayerParam = D2D1::LayerParameters();
|
||||
}
|
||||
|
||||
void e2d::TransitionBase::_update()
|
||||
{
|
||||
// 计算动画进度
|
||||
if (m_fDuration == 0)
|
||||
if (_fDuration == 0)
|
||||
{
|
||||
m_fRateOfProgress = 1;
|
||||
_fRateOfProgress = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
_fRateOfProgress = min((Time::getTotalTime() - _fLast) / _fDuration, 1);
|
||||
}
|
||||
|
||||
this->_updateCustom();
|
||||
|
||||
// 更新场景内容
|
||||
if (m_pPrevScene)
|
||||
if (_pPrevScene)
|
||||
{
|
||||
m_pPrevScene->_update();
|
||||
_pPrevScene->_update();
|
||||
}
|
||||
if (m_pNextScene)
|
||||
if (_pNextScene)
|
||||
{
|
||||
m_pNextScene->_update();
|
||||
_pNextScene->_update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,41 +87,41 @@ void e2d::TransitionBase::_render()
|
|||
{
|
||||
auto pRT = Renderer::getRenderTarget();
|
||||
|
||||
if (m_pPrevScene)
|
||||
if (_pPrevScene)
|
||||
{
|
||||
Point rootPos = m_pPrevScene->getRoot()->getPos();
|
||||
Point rootPos = _pPrevScene->getRoot()->getPos();
|
||||
auto clipRect = D2D1::RectF(
|
||||
float(max(rootPos.x, 0)),
|
||||
float(max(rootPos.y, 0)),
|
||||
float(min(rootPos.x + m_WindowSize.width, m_WindowSize.width)),
|
||||
float(min(rootPos.y + m_WindowSize.height, m_WindowSize.height))
|
||||
float(min(rootPos.x + _WindowSize.width, _WindowSize.width)),
|
||||
float(min(rootPos.y + _WindowSize.height, _WindowSize.height))
|
||||
);
|
||||
pRT->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
|
||||
pRT->PushLayer(m_sPrevLayerParam, m_pPrevLayer);
|
||||
pRT->PushLayer(_sPrevLayerParam, _pPrevLayer);
|
||||
|
||||
// 渲染场景
|
||||
m_pPrevScene->_render();
|
||||
_pPrevScene->_render();
|
||||
|
||||
pRT->PopLayer();
|
||||
pRT->PopAxisAlignedClip();
|
||||
}
|
||||
|
||||
if (m_pNextScene)
|
||||
if (_pNextScene)
|
||||
{
|
||||
Point rootPos = m_pNextScene->getRoot()->getPos();
|
||||
Point rootPos = _pNextScene->getRoot()->getPos();
|
||||
auto clipRect = D2D1::RectF(
|
||||
float(max(rootPos.x, 0)),
|
||||
float(max(rootPos.y, 0)),
|
||||
float(min(rootPos.x + m_WindowSize.width, m_WindowSize.width)),
|
||||
float(min(rootPos.y + m_WindowSize.height, m_WindowSize.height))
|
||||
float(min(rootPos.x + _WindowSize.width, _WindowSize.width)),
|
||||
float(min(rootPos.y + _WindowSize.height, _WindowSize.height))
|
||||
);
|
||||
pRT->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
|
||||
pRT->PushLayer(m_sNextLayerParam, m_pNextLayer);
|
||||
pRT->PushLayer(_sNextLayerParam, _pNextLayer);
|
||||
|
||||
// 渲染场景
|
||||
m_pNextScene->_render();
|
||||
_pNextScene->_render();
|
||||
|
||||
pRT->PopLayer();
|
||||
pRT->PopAxisAlignedClip();
|
||||
|
|
@ -130,6 +130,6 @@ void e2d::TransitionBase::_render()
|
|||
|
||||
void e2d::TransitionBase::_stop()
|
||||
{
|
||||
m_bEnd = true;
|
||||
_bEnd = true;
|
||||
_reset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ e2d::TransitionEmerge::TransitionEmerge(double duration)
|
|||
void e2d::TransitionEmerge::_init(Scene * prev, Scene * next)
|
||||
{
|
||||
TransitionBase::_init(prev, next);
|
||||
m_sPrevLayerParam.opacity = 1;
|
||||
m_sNextLayerParam.opacity = 0;
|
||||
_sPrevLayerParam.opacity = 1;
|
||||
_sNextLayerParam.opacity = 0;
|
||||
}
|
||||
|
||||
void e2d::TransitionEmerge::_updateCustom()
|
||||
{
|
||||
m_sPrevLayerParam.opacity = float(1 - m_fRateOfProgress);
|
||||
m_sNextLayerParam.opacity = float(m_fRateOfProgress);
|
||||
_sPrevLayerParam.opacity = float(1 - _fRateOfProgress);
|
||||
_sNextLayerParam.opacity = float(_fRateOfProgress);
|
||||
|
||||
if (m_fRateOfProgress >= 1)
|
||||
if (_fRateOfProgress >= 1)
|
||||
{
|
||||
this->_stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,53 +3,53 @@
|
|||
|
||||
e2d::TransitionFade::TransitionFade(double duration)
|
||||
: TransitionBase(0)
|
||||
, m_fFadeOutDuration(max(duration / 2, 0))
|
||||
, m_fFadeInDuration(max(duration / 2, 0))
|
||||
, m_bFadeOutTransioning(true)
|
||||
, _fFadeOutDuration(max(duration / 2, 0))
|
||||
, _fFadeInDuration(max(duration / 2, 0))
|
||||
, _bFadeOutTransioning(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration)
|
||||
: TransitionBase(0)
|
||||
, m_fFadeOutDuration(max(fadeOutDuration, 0))
|
||||
, m_fFadeInDuration(max(fadeInDuration, 0))
|
||||
, m_bFadeOutTransioning(true)
|
||||
, _fFadeOutDuration(max(fadeOutDuration, 0))
|
||||
, _fFadeInDuration(max(fadeInDuration, 0))
|
||||
, _bFadeOutTransioning(true)
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::TransitionFade::_init(Scene * prev, Scene * next)
|
||||
{
|
||||
TransitionBase::_init(prev, next);
|
||||
if (m_pPrevScene)
|
||||
if (_pPrevScene)
|
||||
{
|
||||
m_bFadeOutTransioning = true;
|
||||
m_fDuration = m_fFadeOutDuration;
|
||||
_bFadeOutTransioning = true;
|
||||
_fDuration = _fFadeOutDuration;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bFadeOutTransioning = false;
|
||||
m_fDuration = m_fFadeInDuration;
|
||||
_bFadeOutTransioning = false;
|
||||
_fDuration = _fFadeInDuration;
|
||||
}
|
||||
m_sPrevLayerParam.opacity = 1;
|
||||
m_sNextLayerParam.opacity = 0;
|
||||
_sPrevLayerParam.opacity = 1;
|
||||
_sNextLayerParam.opacity = 0;
|
||||
}
|
||||
|
||||
void e2d::TransitionFade::_updateCustom()
|
||||
{
|
||||
if (m_bFadeOutTransioning)
|
||||
if (_bFadeOutTransioning)
|
||||
{
|
||||
m_sPrevLayerParam.opacity = float(1 - m_fRateOfProgress);
|
||||
if (m_fRateOfProgress >= 1)
|
||||
_sPrevLayerParam.opacity = float(1 - _fRateOfProgress);
|
||||
if (_fRateOfProgress >= 1)
|
||||
{
|
||||
m_bFadeOutTransioning = false;
|
||||
m_fDuration = m_fFadeInDuration;
|
||||
m_fLast = Time::getTotalTime();
|
||||
_bFadeOutTransioning = false;
|
||||
_fDuration = _fFadeInDuration;
|
||||
_fLast = Time::getTotalTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sNextLayerParam.opacity = float(m_fRateOfProgress);
|
||||
if (m_fRateOfProgress >= 1)
|
||||
_sNextLayerParam.opacity = float(_fRateOfProgress);
|
||||
if (_fRateOfProgress >= 1)
|
||||
{
|
||||
this->_stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
e2d::TransitionMove::TransitionMove(double duration, Direct direct)
|
||||
: TransitionBase(duration)
|
||||
, m_Direct(direct)
|
||||
, _Direct(direct)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -11,45 +11,45 @@ void e2d::TransitionMove::_init(Scene * prev, Scene * next)
|
|||
{
|
||||
TransitionBase::_init(prev, next);
|
||||
|
||||
double width = m_WindowSize.width;
|
||||
double height = m_WindowSize.height;
|
||||
if (m_Direct == Direct::UP)
|
||||
double width = _WindowSize.width;
|
||||
double height = _WindowSize.height;
|
||||
if (_Direct == Direct::UP)
|
||||
{
|
||||
m_Vector = Vector(0, -height);
|
||||
m_NextPos = Point(0, height);
|
||||
_Vector = Vector(0, -height);
|
||||
_NextPos = Point(0, height);
|
||||
}
|
||||
else if (m_Direct == Direct::DOWN)
|
||||
else if (_Direct == Direct::DOWN)
|
||||
{
|
||||
m_Vector = Vector(0, height);
|
||||
m_NextPos = Point(0, -height);
|
||||
_Vector = Vector(0, height);
|
||||
_NextPos = Point(0, -height);
|
||||
}
|
||||
else if (m_Direct == Direct::LEFT)
|
||||
else if (_Direct == Direct::LEFT)
|
||||
{
|
||||
m_Vector = Vector(-width, 0);
|
||||
m_NextPos = Point(width, 0);
|
||||
_Vector = Vector(-width, 0);
|
||||
_NextPos = Point(width, 0);
|
||||
}
|
||||
else if (m_Direct == Direct::RIGHT)
|
||||
else if (_Direct == Direct::RIGHT)
|
||||
{
|
||||
m_Vector = Vector(width, 0);
|
||||
m_NextPos = Point(-width, 0);
|
||||
_Vector = Vector(width, 0);
|
||||
_NextPos = Point(-width, 0);
|
||||
}
|
||||
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
|
||||
m_pNextScene->getRoot()->setPos(m_NextPos);
|
||||
if (_pPrevScene) _pPrevScene->getRoot()->setPos(0, 0);
|
||||
_pNextScene->getRoot()->setPos(_NextPos);
|
||||
}
|
||||
|
||||
void e2d::TransitionMove::_updateCustom()
|
||||
{
|
||||
if (m_pPrevScene)
|
||||
if (_pPrevScene)
|
||||
{
|
||||
m_pPrevScene->getRoot()->setPos(m_Vector * m_fRateOfProgress);
|
||||
_pPrevScene->getRoot()->setPos(_Vector * _fRateOfProgress);
|
||||
}
|
||||
if (m_pNextScene)
|
||||
if (_pNextScene)
|
||||
{
|
||||
m_pNextScene->getRoot()->setPos(m_NextPos + m_Vector * m_fRateOfProgress);
|
||||
_pNextScene->getRoot()->setPos(_NextPos + _Vector * _fRateOfProgress);
|
||||
}
|
||||
|
||||
if (m_fRateOfProgress >= 1)
|
||||
if (_fRateOfProgress >= 1)
|
||||
{
|
||||
this->_stop();
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ void e2d::TransitionMove::_updateCustom()
|
|||
|
||||
void e2d::TransitionMove::_reset()
|
||||
{
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
|
||||
m_pNextScene->getRoot()->setPos(0, 0);
|
||||
if (_pPrevScene) _pPrevScene->getRoot()->setPos(0, 0);
|
||||
_pNextScene->getRoot()->setPos(0, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
128
core/e2daction.h
128
core/e2daction.h
|
|
@ -170,11 +170,6 @@ public:
|
|||
// 获取动作运行状态
|
||||
virtual bool isRunning();
|
||||
|
||||
// 开始动作
|
||||
virtual void startWithTarget(
|
||||
Node* target /* 执行该动作的目标 */
|
||||
);
|
||||
|
||||
// 继续动作
|
||||
virtual void resume();
|
||||
|
||||
|
|
@ -192,12 +187,12 @@ public:
|
|||
const String& name
|
||||
);
|
||||
|
||||
// 获取一个新的逆向动作
|
||||
virtual ActionBase * reverse() const;
|
||||
|
||||
// 获取一个新的拷贝动作
|
||||
// 获取动作的拷贝
|
||||
virtual ActionBase * clone() const = 0;
|
||||
|
||||
// 获取动作的倒转
|
||||
virtual ActionBase * reverse() const;
|
||||
|
||||
// 重置动作
|
||||
virtual void reset();
|
||||
|
||||
|
|
@ -220,14 +215,19 @@ protected:
|
|||
// 重置动画时间
|
||||
virtual void _resetTime();
|
||||
|
||||
// 开始动作
|
||||
virtual void _startWithTarget(
|
||||
Node* target
|
||||
);
|
||||
|
||||
protected:
|
||||
String m_sName;
|
||||
bool m_bRunning;
|
||||
bool m_bEnding;
|
||||
bool m_bInit;
|
||||
Node * m_pTarget;
|
||||
Scene * m_pParentScene;
|
||||
double m_fLast;
|
||||
String _sName;
|
||||
bool _bRunning;
|
||||
bool _bEnding;
|
||||
bool _bInit;
|
||||
Node * _pTarget;
|
||||
Scene * _pParentScene;
|
||||
double _fLast;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -249,8 +249,8 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_fDuration;
|
||||
double m_fRateOfProgress;
|
||||
double _fDuration;
|
||||
double _fRateOfProgress;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ public:
|
|||
// 获取该动画的拷贝对象
|
||||
virtual ActionMoveBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
// 获取该动画的倒转
|
||||
virtual ActionMoveBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
|
|
@ -279,8 +279,8 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
Point m_BeginPos;
|
||||
Vector m_MoveVec;
|
||||
Point _BeginPos;
|
||||
Vector _MoveVec;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ protected:
|
|||
virtual void _init() override;
|
||||
|
||||
protected:
|
||||
Point m_EndPos;
|
||||
Point _EndPos;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ public:
|
|||
// 获取该动画的拷贝对象
|
||||
virtual ActionScaleBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
// 获取该动画的倒转
|
||||
virtual ActionScaleBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
|
|
@ -339,10 +339,10 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_nBeginScaleX;
|
||||
double m_nBeginScaleY;
|
||||
double m_nVariationX;
|
||||
double m_nVariationY;
|
||||
double _nBeginScaleX;
|
||||
double _nBeginScaleY;
|
||||
double _nVariationX;
|
||||
double _nVariationY;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -372,8 +372,8 @@ protected:
|
|||
virtual void _init() override;
|
||||
|
||||
protected:
|
||||
double m_nEndScaleX;
|
||||
double m_nEndScaleY;
|
||||
double _nEndScaleX;
|
||||
double _nEndScaleY;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ public:
|
|||
// 获取该动画的拷贝对象
|
||||
virtual ActionOpacityBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
// 获取该动画的倒转
|
||||
virtual ActionOpacityBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
|
|
@ -402,8 +402,8 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_nBeginVal;
|
||||
double m_nVariation;
|
||||
double _nBeginVal;
|
||||
double _nVariation;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ protected:
|
|||
virtual void _init() override;
|
||||
|
||||
protected:
|
||||
double m_nEndVal;
|
||||
double _nEndVal;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -437,8 +437,11 @@ class ActionFadeIn :
|
|||
public:
|
||||
// 创建淡入动画
|
||||
ActionFadeIn(
|
||||
double duration /* 动画持续时长 */
|
||||
) : ActionOpacityTo(duration, 1) {}
|
||||
double duration /* 动画持续时长 */
|
||||
)
|
||||
: ActionOpacityTo(duration, 1)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -449,8 +452,11 @@ class ActionFadeOut :
|
|||
public:
|
||||
// 创建淡出动画
|
||||
ActionFadeOut(
|
||||
double duration /* 动画持续时长 */
|
||||
) : ActionOpacityTo(duration, 0) {}
|
||||
double duration /* 动画持续时长 */
|
||||
)
|
||||
: ActionOpacityTo(duration, 0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -468,7 +474,7 @@ public:
|
|||
// 获取该动画的拷贝对象
|
||||
virtual ActionRotateBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
// 获取该动画的倒转
|
||||
virtual ActionRotateBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
|
|
@ -479,8 +485,8 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_nBeginVal;
|
||||
double m_nVariation;
|
||||
double _nBeginVal;
|
||||
double _nVariation;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -503,7 +509,7 @@ protected:
|
|||
virtual void _init() override;
|
||||
|
||||
protected:
|
||||
double m_nEndVal;
|
||||
double _nEndVal;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -516,7 +522,7 @@ public:
|
|||
ActionTwo(
|
||||
ActionBase * pActionFirst, /* 第一个动作 */
|
||||
ActionBase * pActionSecond, /* 第二个动作 */
|
||||
bool bAtSameTime = false /* 同时开始 */
|
||||
bool bAtSameTime = false /* 同时开始 */
|
||||
);
|
||||
|
||||
virtual ~ActionTwo();
|
||||
|
|
@ -524,9 +530,9 @@ public:
|
|||
// 获取该动作的拷贝对象
|
||||
virtual ActionTwo * clone() const override;
|
||||
|
||||
// 获取该动作的逆动作
|
||||
// 获取该动作的倒转
|
||||
virtual ActionTwo * reverse(
|
||||
bool actionReverse = true /* 子动作是否执行逆动作 */
|
||||
bool actionReverse = true /* 子动作是否倒转 */
|
||||
) const;
|
||||
|
||||
// 重置动作
|
||||
|
|
@ -546,9 +552,9 @@ protected:
|
|||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
ActionBase* m_pFirstAction;
|
||||
ActionBase* m_pSecondAction;
|
||||
bool m_bAtSameTime;
|
||||
ActionBase* _pFirstAction;
|
||||
ActionBase* _pSecondAction;
|
||||
bool _bAtSameTime;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -568,7 +574,7 @@ public:
|
|||
#else
|
||||
// 创建顺序动作
|
||||
ActionSequence(
|
||||
int number, /* 动作数量 */
|
||||
int number, /* 动作数量 */
|
||||
ActionBase * action, /* 第一个动作 */
|
||||
...
|
||||
);
|
||||
|
|
@ -598,9 +604,9 @@ public:
|
|||
// 获取该动作的拷贝对象
|
||||
virtual ActionSequence * clone() const override;
|
||||
|
||||
// 获取该动作的逆动作
|
||||
// 获取该动作的倒转
|
||||
virtual ActionSequence * reverse(
|
||||
bool actionReverse = true /* 子动作是否执行逆动作 */
|
||||
bool actionReverse = true /* 子动作是否倒转 */
|
||||
) const;
|
||||
|
||||
// 重置动作
|
||||
|
|
@ -620,8 +626,8 @@ protected:
|
|||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
UINT m_nActionIndex;
|
||||
std::vector<ActionBase*> m_vActions;
|
||||
UINT _nActionIndex;
|
||||
std::vector<ActionBase*> _vActions;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -646,7 +652,7 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_fDelayTime;
|
||||
double _fDelayTime;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -683,9 +689,9 @@ protected:
|
|||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
ActionBase * m_pAction;
|
||||
int m_nTimes;
|
||||
int m_nTotalTimes;
|
||||
ActionBase * _pAction;
|
||||
int _nTimes;
|
||||
int _nTotalTimes;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -759,7 +765,7 @@ public:
|
|||
// 获取该动画的拷贝对象
|
||||
virtual Animation * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
// 获取该动画的倒转
|
||||
virtual Animation * reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
|
|
@ -776,9 +782,9 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
double m_fInterval;
|
||||
UINT m_nFrameIndex;
|
||||
std::vector<Image*> m_vFrames;
|
||||
double _fInterval;
|
||||
UINT _nFrameIndex;
|
||||
std::vector<Image*> _vFrames;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -803,7 +809,7 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
Function m_Callback;
|
||||
Function _Callback;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,12 +65,12 @@ protected:
|
|||
virtual void _render();
|
||||
|
||||
protected:
|
||||
bool m_bEnable;
|
||||
bool m_bIsVisiable;
|
||||
bool m_bAutoResize;
|
||||
Color m_nColor;
|
||||
Node * m_pParentNode;
|
||||
ID2D1TransformedGeometry * m_pTransformedGeometry;
|
||||
bool _bEnable;
|
||||
bool _bIsVisiable;
|
||||
bool _bAutoResize;
|
||||
Color _nColor;
|
||||
Node * _pParentNode;
|
||||
ID2D1TransformedGeometry * _pTransformedGeometry;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ protected:
|
|||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1RectangleGeometry * m_pD2dRectangle;
|
||||
ID2D1RectangleGeometry * _pD2dRectangle;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ protected:
|
|||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dCircle;
|
||||
ID2D1EllipseGeometry * _pD2dCircle;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ protected:
|
|||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dEllipse;
|
||||
ID2D1EllipseGeometry * _pD2dEllipse;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ public:
|
|||
friend std::wistream& operator>> (std::wistream &, String &);
|
||||
|
||||
private:
|
||||
std::wstring m_str;
|
||||
std::wstring _str;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ public:
|
|||
);
|
||||
|
||||
template<typename Func>
|
||||
Function(Func func) : m_func(func) {}
|
||||
Function(Func func) : _func(func) {}
|
||||
|
||||
template<typename Func, typename Object>
|
||||
Function(
|
||||
|
|
@ -560,7 +560,7 @@ public:
|
|||
Object&& obj
|
||||
)
|
||||
{
|
||||
m_func = std::bind(func, obj);
|
||||
_func = std::bind(func, obj);
|
||||
}
|
||||
|
||||
void operator() (void) const;
|
||||
|
|
@ -568,7 +568,7 @@ public:
|
|||
operator bool() const;
|
||||
|
||||
protected:
|
||||
std::function<void()> m_func;
|
||||
std::function<void()> _func;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ public:
|
|||
virtual void destroy() {}
|
||||
|
||||
private:
|
||||
int m_nRefCount;
|
||||
int _nRefCount;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -701,11 +701,11 @@ public:
|
|||
static void clearCache();
|
||||
|
||||
protected:
|
||||
double m_fSourceCropX;
|
||||
double m_fSourceCropY;
|
||||
double m_fSourceCropWidth;
|
||||
double m_fSourceCropHeight;
|
||||
ID2D1Bitmap * m_pBitmap;
|
||||
double _fSourceCropX;
|
||||
double _fSourceCropY;
|
||||
double _fSourceCropWidth;
|
||||
double _fSourceCropHeight;
|
||||
ID2D1Bitmap * _pBitmap;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -799,11 +799,11 @@ protected:
|
|||
void _update();
|
||||
|
||||
protected:
|
||||
bool m_bAutoUpdate;
|
||||
bool m_bSortNeeded;
|
||||
bool m_bWillSave;
|
||||
bool m_bColliderVisiable;
|
||||
Node * m_pRoot;
|
||||
bool _bAutoUpdate;
|
||||
bool _bSortNeeded;
|
||||
bool _bWillSave;
|
||||
bool _bColliderVisiable;
|
||||
Node * _pRoot;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,13 @@ class ActionManager
|
|||
friend ActionBase;
|
||||
|
||||
public:
|
||||
// 执行动作
|
||||
static void start(
|
||||
ActionBase * action,
|
||||
Node * target,
|
||||
bool paused
|
||||
);
|
||||
|
||||
// 继续名称相同的所有动作
|
||||
static void resume(
|
||||
const String& strActionName
|
||||
|
|
@ -131,38 +138,32 @@ private:
|
|||
|
||||
// 添加动作
|
||||
static void __add(
|
||||
ActionBase * pAction
|
||||
ActionBase * action
|
||||
);
|
||||
|
||||
// 删除动作
|
||||
static void __remove(
|
||||
ActionBase * pAction
|
||||
);
|
||||
|
||||
// 执行动作
|
||||
static void __startAction(
|
||||
ActionBase * pAction,
|
||||
Node * pTargetNode
|
||||
ActionBase * action
|
||||
);
|
||||
|
||||
// 继续绑定在节点上的所有动作
|
||||
static void __resumeAllBindedWith(
|
||||
Node * pTargetNode
|
||||
Node * target
|
||||
);
|
||||
|
||||
// 暂停绑定在节点上的所有动作
|
||||
static void __pauseAllBindedWith(
|
||||
Node * pTargetNode
|
||||
Node * target
|
||||
);
|
||||
|
||||
// 停止绑定在节点上的所有动作
|
||||
static void __stopAllBindedWith(
|
||||
Node * pTargetNode
|
||||
Node * target
|
||||
);
|
||||
|
||||
// 清空绑定在节点上的所有动作
|
||||
static void __clearAllBindedWith(
|
||||
Node * pTargetNode
|
||||
Node * target
|
||||
);
|
||||
|
||||
// 重置所有动作状态
|
||||
|
|
@ -273,7 +274,7 @@ public:
|
|||
// 判断碰撞是否由该节点引发
|
||||
// 如果是,返回与其相撞的节点指针,否则返回空
|
||||
static Node * isCausedBy(
|
||||
Node * pNode
|
||||
Node * node
|
||||
);
|
||||
|
||||
// 判断发生碰撞的节点名称是否相同
|
||||
|
|
|
|||
108
core/e2dnode.h
108
core/e2dnode.h
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
// 碰撞处理
|
||||
virtual void onCollide(
|
||||
Node* pNode /* ·¢ÉúÅöײµÄ½Úµã */
|
||||
Node* node /* ˇ˘ÉúĹöײľÄ˝Úľă */
|
||||
) {}
|
||||
|
||||
// 获取节点显示状态
|
||||
|
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
// 判断两节点是否相交
|
||||
virtual bool isIntersectWith(
|
||||
const Node * pNode
|
||||
const Node * node
|
||||
) const;
|
||||
|
||||
// 获取节点名称
|
||||
|
|
@ -442,34 +442,34 @@ protected:
|
|||
void _updateOpacity();
|
||||
|
||||
protected:
|
||||
String m_sName;
|
||||
unsigned m_nHashName;
|
||||
float m_fPosX;
|
||||
float m_fPosY;
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
float m_fScaleX;
|
||||
float m_fScaleY;
|
||||
float m_fRotation;
|
||||
float m_fSkewAngleX;
|
||||
float m_fSkewAngleY;
|
||||
float m_fDisplayOpacity;
|
||||
float m_fRealOpacity;
|
||||
float m_fPivotX;
|
||||
float m_fPivotY;
|
||||
int m_nOrder;
|
||||
bool m_bVisiable;
|
||||
bool m_bAutoUpdate;
|
||||
bool m_bSortChildrenNeeded;
|
||||
bool m_bTransformNeeded;
|
||||
bool m_bPositionFixed;
|
||||
Collider * m_pCollider;
|
||||
Scene * m_pParentScene;
|
||||
Node * m_pParent;
|
||||
D2D1::Matrix3x2F m_MatriInitial;
|
||||
D2D1::Matrix3x2F m_MatriFinal;
|
||||
std::set<unsigned int> m_vColliders;
|
||||
std::vector<Node*> m_vChildren;
|
||||
String _sName;
|
||||
unsigned _nHashName;
|
||||
float _fPosX;
|
||||
float _fPosY;
|
||||
float _fWidth;
|
||||
float _fHeight;
|
||||
float _fScaleX;
|
||||
float _fScaleY;
|
||||
float _fRotation;
|
||||
float _fSkewAngleX;
|
||||
float _fSkewAngleY;
|
||||
float _fDisplayOpacity;
|
||||
float _fRealOpacity;
|
||||
float _fPivotX;
|
||||
float _fPivotY;
|
||||
int _nOrder;
|
||||
bool _bVisiable;
|
||||
bool _bAutoUpdate;
|
||||
bool _bSortChildrenNeeded;
|
||||
bool _bTransformNeeded;
|
||||
bool _bPositionFixed;
|
||||
Collider * _pCollider;
|
||||
Scene * _pParentScene;
|
||||
Node * _pParent;
|
||||
D2D1::Matrix3x2F _MatriInitial;
|
||||
D2D1::Matrix3x2F _MatriFinal;
|
||||
std::set<unsigned int> _vColliders;
|
||||
std::vector<Node*> _vChildren;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -551,7 +551,7 @@ public:
|
|||
virtual void destroy() override;
|
||||
|
||||
protected:
|
||||
Image * m_pImage;
|
||||
Image * _pImage;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -735,10 +735,10 @@ protected:
|
|||
void _createLayout();
|
||||
|
||||
protected:
|
||||
String m_sText;
|
||||
TextStyle m_TextStyle;
|
||||
IDWriteTextFormat * m_pDWriteTextFormat;
|
||||
IDWriteTextLayout * m_pDWriteTextLayout;
|
||||
String _sText;
|
||||
TextStyle _TextStyle;
|
||||
IDWriteTextFormat * _pDWriteTextFormat;
|
||||
IDWriteTextLayout * _pDWriteTextLayout;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -829,14 +829,14 @@ protected:
|
|||
virtual void _runCallback();
|
||||
|
||||
protected:
|
||||
Node * m_pNormal;
|
||||
Node * m_pMouseover;
|
||||
Node * m_pSelected;
|
||||
Node * m_pDisabled;
|
||||
bool m_bEnable;
|
||||
bool m_bIsSelected;
|
||||
ButtonState m_eBtnState;
|
||||
Function m_Callback;
|
||||
Node * _pNormal;
|
||||
Node * _pMouseover;
|
||||
Node * _pSelected;
|
||||
Node * _pDisabled;
|
||||
bool _bEnable;
|
||||
bool _bIsSelected;
|
||||
ButtonState _eBtnState;
|
||||
Function _Callback;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -943,15 +943,15 @@ protected:
|
|||
virtual void _runCallback() override;
|
||||
|
||||
protected:
|
||||
Node * m_pNormalOn;
|
||||
Node * m_pNormalOff;
|
||||
Node * m_pMouseoverOn;
|
||||
Node * m_pMouseoverOff;
|
||||
Node * m_pSelectedOn;
|
||||
Node * m_pSelectedOff;
|
||||
Node * m_pDisabledOn;
|
||||
Node * m_pDisabledOff;
|
||||
bool m_bState;
|
||||
Node * _pNormalOn;
|
||||
Node * _pNormalOff;
|
||||
Node * _pMouseoverOn;
|
||||
Node * _pMouseoverOff;
|
||||
Node * _pSelectedOn;
|
||||
Node * _pSelectedOff;
|
||||
Node * _pDisabledOn;
|
||||
Node * _pDisabledOff;
|
||||
bool _bState;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -998,8 +998,8 @@ public:
|
|||
);
|
||||
|
||||
protected:
|
||||
bool m_bEnable;
|
||||
std::vector<Button*> m_vButtons;
|
||||
bool _bEnable;
|
||||
std::vector<Button*> _vButtons;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -55,10 +55,10 @@ protected:
|
|||
virtual void _renderFill() = 0;
|
||||
|
||||
protected:
|
||||
ShapeStyle m_nStyle;
|
||||
float m_fStrokeWidth;
|
||||
Color m_nLineColor;
|
||||
Color m_nFillColor;
|
||||
ShapeStyle _nStyle;
|
||||
float _fStrokeWidth;
|
||||
Color _nLineColor;
|
||||
Color _nFillColor;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -163,8 +163,8 @@ protected:
|
|||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
float m_fRadiusX;
|
||||
float m_fRadiusY;
|
||||
float _fRadiusX;
|
||||
float _fRadiusY;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ protected:
|
|||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
float m_fRadius;
|
||||
float _fRadius;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -263,8 +263,8 @@ protected:
|
|||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
float m_fRadiusX;
|
||||
float m_fRadiusY;
|
||||
float _fRadiusX;
|
||||
float _fRadiusY;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -79,17 +79,17 @@ protected:
|
|||
virtual void _stop();
|
||||
|
||||
protected:
|
||||
bool m_bEnd;
|
||||
double m_fLast;
|
||||
double m_fDuration;
|
||||
double m_fRateOfProgress;
|
||||
Size m_WindowSize;
|
||||
Scene * m_pPrevScene;
|
||||
Scene * m_pNextScene;
|
||||
ID2D1Layer * m_pPrevLayer;
|
||||
ID2D1Layer * m_pNextLayer;
|
||||
D2D1_LAYER_PARAMETERS m_sPrevLayerParam;
|
||||
D2D1_LAYER_PARAMETERS m_sNextLayerParam;
|
||||
bool _bEnd;
|
||||
double _fLast;
|
||||
double _fDuration;
|
||||
double _fRateOfProgress;
|
||||
Size _WindowSize;
|
||||
Scene * _pPrevScene;
|
||||
Scene * _pNextScene;
|
||||
ID2D1Layer * _pPrevLayer;
|
||||
ID2D1Layer * _pNextLayer;
|
||||
D2D1_LAYER_PARAMETERS _sPrevLayerParam;
|
||||
D2D1_LAYER_PARAMETERS _sNextLayerParam;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -120,9 +120,9 @@ protected:
|
|||
virtual void _reset() override;
|
||||
|
||||
protected:
|
||||
double m_fFadeOutDuration;
|
||||
double m_fFadeInDuration;
|
||||
bool m_bFadeOutTransioning;
|
||||
double _fFadeOutDuration;
|
||||
double _fFadeInDuration;
|
||||
bool _bFadeOutTransioning;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -170,9 +170,9 @@ protected:
|
|||
virtual void _reset() override;
|
||||
|
||||
protected:
|
||||
Direct m_Direct;
|
||||
Vector m_Vector;
|
||||
Point m_NextPos;
|
||||
Direct _Direct;
|
||||
Vector _Vector;
|
||||
Point _NextPos;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue