细节调整

This commit is contained in:
Nomango 2018-05-08 17:40:36 +08:00
parent a18ff4295d
commit f9181a2080
53 changed files with 1414 additions and 1423 deletions

View File

@ -2,12 +2,12 @@
#include "..\e2dmanager.h" #include "..\e2dmanager.h"
e2d::ActionBase::ActionBase() e2d::ActionBase::ActionBase()
: m_bRunning(false) : _bRunning(false)
, m_bEnding(false) , _bEnding(false)
, m_bInit(false) , _bInit(false)
, m_pTarget(nullptr) , _pTarget(nullptr)
, m_pParentScene(nullptr) , _pParentScene(nullptr)
, m_fLast(0) , _fLast(0)
{ {
ActionManager::__add(this); ActionManager::__add(this);
} }
@ -16,50 +16,47 @@ e2d::ActionBase::~ActionBase()
{ {
} }
bool e2d::ActionBase::isRunning()
{
return m_bRunning;
}
bool e2d::ActionBase::_isDone() bool e2d::ActionBase::_isDone()
{ {
return m_bEnding; return _bEnding;
} }
void e2d::ActionBase::startWithTarget(Node* target) void e2d::ActionBase::_startWithTarget(Node* target)
{ {
if (target) _pTarget = target;
{ _bRunning = true;
m_bRunning = true; this->reset();
m_pTarget = target; }
this->reset();
} bool e2d::ActionBase::isRunning()
{
return _bRunning;
} }
void e2d::ActionBase::resume() void e2d::ActionBase::resume()
{ {
m_bRunning = true; _bRunning = true;
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
} }
void e2d::ActionBase::pause() void e2d::ActionBase::pause()
{ {
m_bRunning = false; _bRunning = false;
} }
void e2d::ActionBase::stop() void e2d::ActionBase::stop()
{ {
m_bEnding = true; _bEnding = true;
} }
e2d::String e2d::ActionBase::getName() const e2d::String e2d::ActionBase::getName() const
{ {
return m_sName; return _sName;
} }
void e2d::ActionBase::setName(const String& name) void e2d::ActionBase::setName(const String& name)
{ {
m_sName = name; _sName = name;
} }
e2d::ActionBase * e2d::ActionBase::reverse() const e2d::ActionBase * e2d::ActionBase::reverse() const
@ -70,7 +67,7 @@ e2d::ActionBase * e2d::ActionBase::reverse() const
e2d::Node * e2d::ActionBase::getTarget() e2d::Node * e2d::ActionBase::getTarget()
{ {
return m_pTarget; return _pTarget;
} }
void e2d::ActionBase::destroy() void e2d::ActionBase::destroy()
@ -80,14 +77,14 @@ void e2d::ActionBase::destroy()
void e2d::ActionBase::_init() void e2d::ActionBase::_init()
{ {
m_bInit = true; _bInit = true;
// ¼Ç¼µ±Ç°Ê±¼ä // ¼Ç¼µ±Ç°Ê±¼ä
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
} }
void e2d::ActionBase::_update() void e2d::ActionBase::_update()
{ {
if (!m_bInit) if (!_bInit)
{ {
_init(); _init();
} }
@ -95,12 +92,12 @@ void e2d::ActionBase::_update()
void e2d::ActionBase::reset() void e2d::ActionBase::reset()
{ {
m_bInit = false; _bInit = false;
m_bEnding = false; _bEnding = false;
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
} }
void e2d::ActionBase::_resetTime() void e2d::ActionBase::_resetTime()
{ {
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
} }

View File

@ -2,12 +2,12 @@
e2d::ActionDelay::ActionDelay(double duration) e2d::ActionDelay::ActionDelay(double duration)
{ {
m_fDelayTime = max(duration, 0); _fDelayTime = max(duration, 0);
} }
e2d::ActionDelay * e2d::ActionDelay::clone() const e2d::ActionDelay * e2d::ActionDelay::clone() const
{ {
return new ActionDelay(m_fDelayTime); return new ActionDelay(_fDelayTime);
} }
void e2d::ActionDelay::_init() void e2d::ActionDelay::_init()
@ -19,7 +19,7 @@ void e2d::ActionDelay::_update()
{ {
ActionBase::_update(); ActionBase::_update();
// 判断时间间隔是否足够 // 判断时间间隔是否足够
if ((Time::getTotalTime() - m_fLast) >= m_fDelayTime) if ((Time::getTotalTime() - _fLast) >= _fDelayTime)
{ {
this->stop(); this->stop();
} }

View File

@ -1,13 +1,13 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::ActionFunc::ActionFunc(const Function& func) : e2d::ActionFunc::ActionFunc(const Function& func) :
m_Callback(func) _Callback(func)
{ {
} }
e2d::ActionFunc * e2d::ActionFunc::clone() const e2d::ActionFunc * e2d::ActionFunc::clone() const
{ {
return new ActionFunc(m_Callback); return new ActionFunc(_Callback);
} }
void e2d::ActionFunc::_init() void e2d::ActionFunc::_init()
@ -17,6 +17,6 @@ void e2d::ActionFunc::_init()
void e2d::ActionFunc::_update() void e2d::ActionFunc::_update()
{ {
m_Callback(); _Callback();
this->stop(); this->stop();
} }

View File

@ -1,9 +1,9 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::ActionGradual::ActionGradual(double duration) e2d::ActionGradual::ActionGradual(double duration)
: m_fRateOfProgress(0) : _fRateOfProgress(0)
{ {
m_fDuration = max(duration, 0); _fDuration = max(duration, 0);
} }
void e2d::ActionGradual::_init() void e2d::ActionGradual::_init()
@ -15,16 +15,16 @@ void e2d::ActionGradual::_update()
{ {
ActionBase::_update(); ActionBase::_update();
// 判断时间间隔是否足够 // 判断时间间隔是否足够
if (m_fDuration == 0) if (_fDuration == 0)
{ {
m_fRateOfProgress = 1; _fRateOfProgress = 1;
this->stop(); this->stop();
return; 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(); this->stop();
} }

View File

@ -2,12 +2,12 @@
#include "..\e2dmanager.h" #include "..\e2dmanager.h"
e2d::ActionLoop::ActionLoop(ActionBase * action, int times /* = -1 */) e2d::ActionLoop::ActionLoop(ActionBase * action, int times /* = -1 */)
: m_pAction(action) : _pAction(action)
, m_nTimes(0) , _nTimes(0)
, m_nTotalTimes(times) , _nTotalTimes(times)
{ {
ASSERT(m_pAction, "ActionLoop NULL pointer exception!"); ASSERT(_pAction, "ActionLoop NULL pointer exception!");
m_pAction->retain(); _pAction->retain();
} }
e2d::ActionLoop::~ActionLoop() e2d::ActionLoop::~ActionLoop()
@ -16,34 +16,34 @@ e2d::ActionLoop::~ActionLoop()
e2d::ActionLoop * e2d::ActionLoop::clone() const e2d::ActionLoop * e2d::ActionLoop::clone() const
{ {
return new ActionLoop(m_pAction->clone()); return new ActionLoop(_pAction->clone());
} }
void e2d::ActionLoop::_init() void e2d::ActionLoop::_init()
{ {
ActionBase::_init(); ActionBase::_init();
m_pAction->m_pTarget = m_pTarget; _pAction->_pTarget = _pTarget;
m_pAction->_init(); _pAction->_init();
} }
void e2d::ActionLoop::_update() void e2d::ActionLoop::_update()
{ {
ActionBase::_update(); ActionBase::_update();
if (m_nTimes == m_nTotalTimes) if (_nTimes == _nTotalTimes)
{ {
this->stop(); this->stop();
return; return;
} }
m_pAction->_update(); _pAction->_update();
if (m_pAction->_isDone()) if (_pAction->_isDone())
{ {
m_nTimes++; _nTimes++;
ActionBase::reset(); ActionBase::reset();
m_pAction->reset(); _pAction->reset();
} }
} }
@ -51,17 +51,17 @@ void e2d::ActionLoop::reset()
{ {
ActionBase::reset(); ActionBase::reset();
m_pAction->reset(); _pAction->reset();
m_nTimes = 0; _nTimes = 0;
} }
void e2d::ActionLoop::destroy() void e2d::ActionLoop::destroy()
{ {
ActionBase::destroy(); ActionBase::destroy();
SafeRelease(&m_pAction); SafeRelease(&_pAction);
} }
void e2d::ActionLoop::_resetTime() void e2d::ActionLoop::_resetTime()
{ {
m_pAction->_resetTime(); _pAction->_resetTime();
} }

View File

@ -4,15 +4,15 @@
e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) : e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) :
ActionGradual(duration) ActionGradual(duration)
{ {
m_MoveVec = vector; _MoveVec = vector;
} }
void e2d::ActionMoveBy::_init() void e2d::ActionMoveBy::_init()
{ {
ActionGradual::_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(); ActionGradual::_update();
if (m_pTarget == nullptr) if (_pTarget == nullptr)
{ {
this->stop(); this->stop();
return; return;
} }
// ÒÆ¶¯½Úµã // ÒÆ¶¯½Úµã
m_pTarget->setPos(m_BeginPos + m_MoveVec * m_fRateOfProgress); _pTarget->setPos(_BeginPos + _MoveVec * _fRateOfProgress);
} }
e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const
{ {
return new ActionMoveBy(m_fDuration, m_MoveVec); return new ActionMoveBy(_fDuration, _MoveVec);
} }
e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const
{ {
return new ActionMoveBy(m_fDuration, -m_MoveVec); return new ActionMoveBy(_fDuration, -_MoveVec);
} }

View File

@ -3,16 +3,16 @@
e2d::ActionMoveTo::ActionMoveTo(double duration, Point pos) : e2d::ActionMoveTo::ActionMoveTo(double duration, Point pos) :
ActionMoveBy(duration, Vector()) ActionMoveBy(duration, Vector())
{ {
m_EndPos = pos; _EndPos = pos;
} }
e2d::ActionMoveTo * e2d::ActionMoveTo::clone() const e2d::ActionMoveTo * e2d::ActionMoveTo::clone() const
{ {
return new ActionMoveTo(m_fDuration, m_EndPos); return new ActionMoveTo(_fDuration, _EndPos);
} }
void e2d::ActionMoveTo::_init() void e2d::ActionMoveTo::_init()
{ {
ActionMoveBy::_init(); ActionMoveBy::_init();
m_MoveVec = m_EndPos - m_BeginPos; _MoveVec = _EndPos - _BeginPos;
} }

View File

@ -4,15 +4,15 @@
e2d::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) : e2d::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) :
ActionGradual(duration) ActionGradual(duration)
{ {
m_nVariation = opacity; _nVariation = opacity;
} }
void e2d::ActionOpacityBy::_init() void e2d::ActionOpacityBy::_init()
{ {
ActionGradual::_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(); ActionGradual::_update();
if (m_pTarget == nullptr) if (_pTarget == nullptr)
{ {
this->stop(); this->stop();
return; return;
} }
// 设置节点透明度 // 设置节点透明度
m_pTarget->setOpacity(m_nBeginVal + m_nVariation * m_fRateOfProgress); _pTarget->setOpacity(_nBeginVal + _nVariation * _fRateOfProgress);
} }
e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const
{ {
return new ActionOpacityBy(m_fDuration, m_nVariation); return new ActionOpacityBy(_fDuration, _nVariation);
} }
e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const
{ {
return new ActionOpacityBy(m_fDuration, -m_nVariation); return new ActionOpacityBy(_fDuration, -_nVariation);
} }

View File

@ -4,16 +4,16 @@
e2d::ActionOpacityTo::ActionOpacityTo(double duration, double opacity) : e2d::ActionOpacityTo::ActionOpacityTo(double duration, double opacity) :
ActionOpacityBy(duration, 0) ActionOpacityBy(duration, 0)
{ {
m_nEndVal = opacity; _nEndVal = opacity;
} }
e2d::ActionOpacityTo * e2d::ActionOpacityTo::clone() const e2d::ActionOpacityTo * e2d::ActionOpacityTo::clone() const
{ {
return new ActionOpacityTo(m_fDuration, m_nEndVal); return new ActionOpacityTo(_fDuration, _nEndVal);
} }
void e2d::ActionOpacityTo::_init() void e2d::ActionOpacityTo::_init()
{ {
ActionOpacityBy::_init(); ActionOpacityBy::_init();
m_nVariation = m_nEndVal - m_nBeginVal; _nVariation = _nEndVal - _nBeginVal;
} }

View File

@ -4,15 +4,15 @@
e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) : e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) :
ActionGradual(duration) ActionGradual(duration)
{ {
m_nVariation = rotation; _nVariation = rotation;
} }
void e2d::ActionRotateBy::_init() void e2d::ActionRotateBy::_init()
{ {
ActionGradual::_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(); ActionGradual::_update();
if (m_pTarget == nullptr) if (_pTarget == nullptr)
{ {
this->stop(); this->stop();
return; return;
} }
// Ðýת½Úµã // Ðýת½Úµã
m_pTarget->setRotation(m_nBeginVal + m_nVariation * m_fRateOfProgress); _pTarget->setRotation(_nBeginVal + _nVariation * _fRateOfProgress);
} }
e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const
{ {
return new ActionRotateBy(m_fDuration, m_nVariation); return new ActionRotateBy(_fDuration, _nVariation);
} }
e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const
{ {
return new ActionRotateBy(m_fDuration, -m_nVariation); return new ActionRotateBy(_fDuration, -_nVariation);
} }

View File

@ -4,16 +4,16 @@
e2d::ActionRotateTo::ActionRotateTo(double duration, double rotation) : e2d::ActionRotateTo::ActionRotateTo(double duration, double rotation) :
ActionRotateBy(duration, 0) ActionRotateBy(duration, 0)
{ {
m_nEndVal = rotation; _nEndVal = rotation;
} }
e2d::ActionRotateTo * e2d::ActionRotateTo::clone() const e2d::ActionRotateTo * e2d::ActionRotateTo::clone() const
{ {
return new ActionRotateTo(m_fDuration, m_nEndVal); return new ActionRotateTo(_fDuration, _nEndVal);
} }
void e2d::ActionRotateTo::_init() void e2d::ActionRotateTo::_init()
{ {
ActionRotateBy::_init(); ActionRotateBy::_init();
m_nVariation = m_nEndVal - m_nBeginVal; _nVariation = _nEndVal - _nBeginVal;
} }

View File

@ -4,24 +4,24 @@
e2d::ActionScaleBy::ActionScaleBy(double duration, double scale) e2d::ActionScaleBy::ActionScaleBy(double duration, double scale)
: ActionGradual(duration) : ActionGradual(duration)
{ {
m_nVariationX = scale; _nVariationX = scale;
m_nVariationY = scale; _nVariationY = scale;
} }
e2d::ActionScaleBy::ActionScaleBy(double duration, double scaleX, double scaleY) e2d::ActionScaleBy::ActionScaleBy(double duration, double scaleX, double scaleY)
: ActionGradual(duration) : ActionGradual(duration)
{ {
m_nVariationX = scaleX; _nVariationX = scaleX;
m_nVariationY = scaleY; _nVariationY = scaleY;
} }
void e2d::ActionScaleBy::_init() void e2d::ActionScaleBy::_init()
{ {
ActionGradual::_init(); ActionGradual::_init();
if (m_pTarget) if (_pTarget)
{ {
m_nBeginScaleX = m_pTarget->getScaleX(); _nBeginScaleX = _pTarget->getScaleX();
m_nBeginScaleY = m_pTarget->getScaleY(); _nBeginScaleY = _pTarget->getScaleY();
} }
} }
@ -29,24 +29,24 @@ void e2d::ActionScaleBy::_update()
{ {
ActionGradual::_update(); ActionGradual::_update();
if (m_pTarget == nullptr) if (_pTarget == nullptr)
{ {
this->stop(); this->stop();
return; return;
} }
// Ëõ·Å½Úµã // Ëõ·Å½Úµã
m_pTarget->setScale( _pTarget->setScale(
m_nBeginScaleX + m_nVariationX * m_fRateOfProgress, _nBeginScaleX + _nVariationX * _fRateOfProgress,
m_nBeginScaleY + m_nVariationY * m_fRateOfProgress); _nBeginScaleY + _nVariationY * _fRateOfProgress);
} }
e2d::ActionScaleBy * e2d::ActionScaleBy::clone() const 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 e2d::ActionScaleBy * e2d::ActionScaleBy::reverse() const
{ {
return new ActionScaleBy(m_fDuration, -m_nVariationX, -m_nVariationY); return new ActionScaleBy(_fDuration, -_nVariationX, -_nVariationY);
} }

View File

@ -3,25 +3,25 @@
e2d::ActionScaleTo::ActionScaleTo(double duration, double scale) e2d::ActionScaleTo::ActionScaleTo(double duration, double scale)
: ActionScaleBy(duration, 0, 0) : ActionScaleBy(duration, 0, 0)
{ {
m_nEndScaleX = scale; _nEndScaleX = scale;
m_nEndScaleY = scale; _nEndScaleY = scale;
} }
e2d::ActionScaleTo::ActionScaleTo(double duration, double scaleX, double scaleY) e2d::ActionScaleTo::ActionScaleTo(double duration, double scaleX, double scaleY)
: ActionScaleBy(duration, 0, 0) : ActionScaleBy(duration, 0, 0)
{ {
m_nEndScaleX = scaleX; _nEndScaleX = scaleX;
m_nEndScaleY = scaleY; _nEndScaleY = scaleY;
} }
e2d::ActionScaleTo * e2d::ActionScaleTo::clone() const 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() void e2d::ActionScaleTo::_init()
{ {
ActionScaleBy::_init(); ActionScaleBy::_init();
m_nVariationX = m_nEndScaleX - m_nBeginScaleX; _nVariationX = _nEndScaleX - _nBeginScaleX;
m_nVariationY = m_nEndScaleY - m_nBeginScaleY; _nVariationY = _nEndScaleY - _nBeginScaleY;
} }

View File

@ -1,19 +1,19 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::ActionSequence::ActionSequence() e2d::ActionSequence::ActionSequence()
: m_nActionIndex(0) : _nActionIndex(0)
{ {
} }
#ifdef HIGHER_THAN_VS2012 #ifdef HIGHER_THAN_VS2012
e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions) e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions)
: m_nActionIndex(0) : _nActionIndex(0)
{ {
this->add(vActions); this->add(vActions);
} }
#else #else
e2d::ActionSequence::ActionSequence(int number, ActionBase * action1, ...) : e2d::ActionSequence::ActionSequence(int number, ActionBase * action1, ...) :
m_nActionIndex(0) _nActionIndex(0)
{ {
ActionBase ** ppAction = &action1; ActionBase ** ppAction = &action1;
@ -35,21 +35,21 @@ void e2d::ActionSequence::_init()
{ {
ActionBase::_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() void e2d::ActionSequence::destroy()
{ {
ActionBase::destroy(); ActionBase::destroy();
for (auto action : m_vActions) for (auto action : _vActions)
{ {
SafeRelease(&action); SafeRelease(&action);
} }
@ -59,19 +59,19 @@ void e2d::ActionSequence::_update()
{ {
ActionBase::_update(); ActionBase::_update();
auto &action = m_vActions[m_nActionIndex]; auto &action = _vActions[_nActionIndex];
action->_update(); action->_update();
if (action->_isDone()) if (action->_isDone())
{ {
m_nActionIndex++; _nActionIndex++;
if (m_nActionIndex == m_vActions.size()) if (_nActionIndex == _vActions.size())
{ {
this->stop(); this->stop();
} }
else else
{ {
m_vActions[m_nActionIndex]->_init(); _vActions[_nActionIndex]->_init();
} }
} }
} }
@ -79,16 +79,16 @@ void e2d::ActionSequence::_update()
void e2d::ActionSequence::reset() void e2d::ActionSequence::reset()
{ {
ActionBase::reset(); ActionBase::reset();
for (auto action : m_vActions) for (auto action : _vActions)
{ {
action->reset(); action->reset();
} }
m_nActionIndex = 0; _nActionIndex = 0;
} }
void e2d::ActionSequence::_resetTime() void e2d::ActionSequence::_resetTime()
{ {
for (auto action : m_vActions) for (auto action : _vActions)
{ {
action->_resetTime(); action->_resetTime();
} }
@ -98,7 +98,7 @@ void e2d::ActionSequence::add(ActionBase * action)
{ {
if (action) if (action)
{ {
m_vActions.push_back(action); _vActions.push_back(action);
action->retain(); action->retain();
} }
} }
@ -129,7 +129,7 @@ void e2d::ActionSequence::add(int number, ActionBase * action, ...)
e2d::ActionSequence * e2d::ActionSequence::clone() const e2d::ActionSequence * e2d::ActionSequence::clone() const
{ {
auto a = new ActionSequence(); auto a = new ActionSequence();
for (auto action : m_vActions) for (auto action : _vActions)
{ {
a->add(action->clone()); a->add(action->clone());
} }
@ -139,7 +139,7 @@ e2d::ActionSequence * e2d::ActionSequence::clone() const
e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const
{ {
auto a = new ActionSequence(); auto a = new ActionSequence();
for (auto action : m_vActions) for (auto action : _vActions)
{ {
if (actionReverse) 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; return a;
} }

View File

@ -1,13 +1,13 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::ActionTwo::ActionTwo(ActionBase * pActionFirst, ActionBase * pActionSecond, bool bAtSameTime/* = false*/) e2d::ActionTwo::ActionTwo(ActionBase * pActionFirst, ActionBase * pActionSecond, bool bAtSameTime/* = false*/)
: m_pFirstAction(pActionFirst) : _pFirstAction(pActionFirst)
, m_pSecondAction(pActionSecond) , _pSecondAction(pActionSecond)
, m_bAtSameTime(bAtSameTime) , _bAtSameTime(bAtSameTime)
{ {
ASSERT(m_pFirstAction && m_pSecondAction, "ActionTwo NULL pointer exception!"); ASSERT(_pFirstAction && _pSecondAction, "ActionTwo NULL pointer exception!");
m_pFirstAction->retain(); _pFirstAction->retain();
m_pSecondAction->retain(); _pSecondAction->retain();
} }
e2d::ActionTwo::~ActionTwo() e2d::ActionTwo::~ActionTwo()
@ -16,58 +16,58 @@ e2d::ActionTwo::~ActionTwo()
e2d::ActionTwo * e2d::ActionTwo::clone() const 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 e2d::ActionTwo * e2d::ActionTwo::reverse(bool actionReverse) const
{ {
if (actionReverse) if (actionReverse)
{ {
return new ActionTwo(m_pSecondAction->reverse(), m_pFirstAction->reverse()); return new ActionTwo(_pSecondAction->reverse(), _pFirstAction->reverse());
} }
else else
{ {
return new ActionTwo(m_pSecondAction->clone(), m_pFirstAction->clone()); return new ActionTwo(_pSecondAction->clone(), _pFirstAction->clone());
} }
} }
void e2d::ActionTwo::_init() void e2d::ActionTwo::_init()
{ {
ActionBase::_init(); ActionBase::_init();
m_pFirstAction->m_pTarget = m_pTarget; _pFirstAction->_pTarget = _pTarget;
m_pSecondAction->m_pTarget = m_pTarget; _pSecondAction->_pTarget = _pTarget;
m_pFirstAction->_init(); _pFirstAction->_init();
if (m_bAtSameTime) m_pSecondAction->_init(); if (_bAtSameTime) _pSecondAction->_init();
} }
void e2d::ActionTwo::_update() void e2d::ActionTwo::_update()
{ {
ActionBase::_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(); this->stop();
} }
@ -77,19 +77,19 @@ void e2d::ActionTwo::reset()
{ {
ActionBase::reset(); ActionBase::reset();
m_pFirstAction->reset(); _pFirstAction->reset();
m_pSecondAction->reset(); _pSecondAction->reset();
} }
void e2d::ActionTwo::destroy() void e2d::ActionTwo::destroy()
{ {
ActionBase::destroy(); ActionBase::destroy();
SafeRelease(&m_pFirstAction); SafeRelease(&_pFirstAction);
SafeRelease(&m_pSecondAction); SafeRelease(&_pSecondAction);
} }
void e2d::ActionTwo::_resetTime() void e2d::ActionTwo::_resetTime()
{ {
m_pFirstAction->_resetTime(); _pFirstAction->_resetTime();
m_pSecondAction->_resetTime(); _pSecondAction->_resetTime();
} }

View File

@ -1,29 +1,29 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::Animation::Animation() e2d::Animation::Animation()
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(1) , _fInterval(1)
{ {
} }
e2d::Animation::Animation(double interval) e2d::Animation::Animation(double interval)
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(interval) , _fInterval(interval)
{ {
} }
#ifdef HIGHER_THAN_VS2012 #ifdef HIGHER_THAN_VS2012
e2d::Animation::Animation(const std::initializer_list<Image*>& vImages) e2d::Animation::Animation(const std::initializer_list<Image*>& vImages)
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(1) , _fInterval(1)
{ {
this->add(vImages); this->add(vImages);
} }
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages) e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages)
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(interval) , _fInterval(interval)
{ {
this->add(vImages); this->add(vImages);
} }
@ -31,8 +31,8 @@ e2d::Animation::Animation(double interval, const std::initializer_list<Image*>&
#else #else
e2d::Animation::Animation(int number, Image * frame, ...) e2d::Animation::Animation(int number, Image * frame, ...)
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(1) , _fInterval(1)
{ {
Image ** ppImage = &frame; Image ** ppImage = &frame;
@ -46,8 +46,8 @@ e2d::Animation::Animation(int number, Image * frame, ...)
} }
e2d::Animation::Animation(double interval, int number, Image * frame, ...) e2d::Animation::Animation(double interval, int number, Image * frame, ...)
: m_nFrameIndex(0) : _nFrameIndex(0)
, m_fInterval(interval) , _fInterval(interval)
{ {
Image ** ppImage = &frame; Image ** ppImage = &frame;
@ -68,7 +68,7 @@ e2d::Animation::~Animation()
void e2d::Animation::setInterval(double interval) void e2d::Animation::setInterval(double interval)
{ {
m_fInterval = max(interval, 0); _fInterval = max(interval, 0);
} }
void e2d::Animation::_init() void e2d::Animation::_init()
@ -80,22 +80,22 @@ void e2d::Animation::_update()
{ {
ActionBase::_update(); ActionBase::_update();
if (m_pTarget == nullptr) if (_pTarget == nullptr)
{ {
this->stop(); this->stop();
return; 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]); static_cast<Sprite*>(_pTarget)->open(_vFrames[_nFrameIndex]);
m_nFrameIndex++; _nFrameIndex++;
// 判断动作是否结束 // 判断动作是否结束
if (m_nFrameIndex == m_vFrames.size()) if (_nFrameIndex == _vFrames.size())
{ {
this->stop(); this->stop();
break; break;
@ -106,13 +106,13 @@ void e2d::Animation::_update()
void e2d::Animation::reset() void e2d::Animation::reset()
{ {
ActionBase::reset(); ActionBase::reset();
m_nFrameIndex = 0; _nFrameIndex = 0;
} }
void e2d::Animation::destroy() void e2d::Animation::destroy()
{ {
ActionBase::destroy(); ActionBase::destroy();
for (auto frame : m_vFrames) for (auto frame : _vFrames)
{ {
SafeRelease(&frame); SafeRelease(&frame);
} }
@ -122,7 +122,7 @@ void e2d::Animation::add(Image * frame)
{ {
if (frame) if (frame)
{ {
m_vFrames.push_back(frame); _vFrames.push_back(frame);
frame->retain(); frame->retain();
} }
} }
@ -152,8 +152,8 @@ void e2d::Animation::add(int number, Image * frame, ...)
e2d::Animation * e2d::Animation::clone() const e2d::Animation * e2d::Animation::clone() const
{ {
auto a = new Animation(m_fInterval); auto a = new Animation(_fInterval);
for (auto frame : m_vFrames) for (auto frame : _vFrames)
{ {
a->add(frame); a->add(frame);
} }
@ -163,6 +163,6 @@ e2d::Animation * e2d::Animation::clone() const
e2d::Animation * e2d::Animation::reverse() const e2d::Animation * e2d::Animation::reverse() const
{ {
auto a = this->clone(); auto a = this->clone();
a->m_vFrames.reserve(m_vFrames.size()); a->_vFrames.reserve(_vFrames.size());
return a; return a;
} }

View File

@ -126,10 +126,10 @@ int e2d::Game::start(bool autoRelease/* true */)
Time::__updateLast(); // 刷新时间信息 Time::__updateLast(); // 刷新时间信息
} }
Renderer::__render(); // 渲染游戏画面 Renderer::__render(); // 渲染游戏画面
ObjectManager::__update(); // 刷新内存池
} }
else else
{ {
ObjectManager::__update(); // 刷新内存池
Time::__sleep(); // 挂起线程 Time::__sleep(); // 挂起线程
} }
} }
@ -204,9 +204,9 @@ void e2d::Game::destroy()
bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle) 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!"); WARN_IF(true, "CreateMutex Failed!");
return true; return true;
@ -216,7 +216,7 @@ bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle
if (::GetLastError() == ERROR_ALREADY_EXISTS) if (::GetLastError() == ERROR_ALREADY_EXISTS)
{ {
// 关闭进程互斥体 // 关闭进程互斥体
::CloseHandle(m_hMutex); ::CloseHandle(_hMutex);
// 打开指定窗口 // 打开指定窗口
if (!sWindowTitle.isEmpty()) if (!sWindowTitle.isEmpty())
{ {

View File

@ -3,73 +3,73 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::Collider::Collider() e2d::Collider::Collider()
: m_bIsVisiable(true) : _bIsVisiable(true)
, m_nColor(Color::RED, 0.7f) , _nColor(Color::RED, 0.7f)
, m_pParentNode(nullptr) , _pParentNode(nullptr)
, m_pTransformedGeometry(nullptr) , _pTransformedGeometry(nullptr)
, m_bEnable(true) , _bEnable(true)
, m_bAutoResize(true) , _bAutoResize(true)
{ {
} }
e2d::Collider::~Collider() e2d::Collider::~Collider()
{ {
SafeReleaseInterface(&m_pTransformedGeometry); SafeReleaseInterface(&_pTransformedGeometry);
} }
e2d::Node * e2d::Collider::getParentNode() const e2d::Node * e2d::Collider::getParentNode() const
{ {
return m_pParentNode; return _pParentNode;
} }
e2d::Color e2d::Collider::getColor() const e2d::Color e2d::Collider::getColor() const
{ {
return m_nColor; return _nColor;
} }
void e2d::Collider::setEnable(bool enable) void e2d::Collider::setEnable(bool enable)
{ {
m_bEnable = enable; _bEnable = enable;
} }
void e2d::Collider::setVisiable(bool bVisiable) void e2d::Collider::setVisiable(bool bVisiable)
{ {
m_bIsVisiable = bVisiable; _bIsVisiable = bVisiable;
} }
void e2d::Collider::setColor(Color color) void e2d::Collider::setColor(Color color)
{ {
m_nColor = color; _nColor = color;
} }
void e2d::Collider::setAutoResize(bool enable) void e2d::Collider::setAutoResize(bool enable)
{ {
m_bAutoResize = enable; _bAutoResize = enable;
} }
void e2d::Collider::_render() void e2d::Collider::_render()
{ {
if (m_pTransformedGeometry && m_bEnable) if (_pTransformedGeometry && _bEnable)
{ {
// 获取纯色画刷 // 获取纯色画刷
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush(); 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 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; D2D1_GEOMETRY_RELATION relation;
m_pTransformedGeometry->CompareWithGeometry( _pTransformedGeometry->CompareWithGeometry(
pCollider->m_pTransformedGeometry, pCollider->_pTransformedGeometry,
D2D1::Matrix3x2F::Identity(), D2D1::Matrix3x2F::Identity(),
&relation &relation
); );
@ -82,21 +82,21 @@ e2d::Relation e2d::Collider::getRelationWith(Collider * pCollider) const
void e2d::Collider::_transform() void e2d::Collider::_transform()
{ {
if (m_pParentNode && m_bEnable) if (_pParentNode && _bEnable)
{ {
if (m_bAutoResize) if (_bAutoResize)
{ {
this->_resize(); this->_resize();
} }
// 释放原碰撞体 // 释放原碰撞体
SafeReleaseInterface(&m_pTransformedGeometry); SafeReleaseInterface(&_pTransformedGeometry);
// 根据父节点转换几何图形 // 根据父节点转换几何图形
Renderer::getID2D1Factory()->CreateTransformedGeometry( Renderer::getID2D1Factory()->CreateTransformedGeometry(
getD2dGeometry(), getD2dGeometry(),
m_pParentNode->m_MatriFinal, _pParentNode->_MatriFinal,
&m_pTransformedGeometry &_pTransformedGeometry
); );
ColliderManager::__updateCollider(this); ColliderManager::__updateCollider(this);

View File

@ -2,18 +2,18 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::ColliderCircle::ColliderCircle() e2d::ColliderCircle::ColliderCircle()
: m_pD2dCircle(nullptr) : _pD2dCircle(nullptr)
{ {
} }
e2d::ColliderCircle::ColliderCircle(Point center, double radius) e2d::ColliderCircle::ColliderCircle(Point center, double radius)
: m_pD2dCircle(nullptr) : _pD2dCircle(nullptr)
{ {
this->setCircle(center, radius); this->setCircle(center, radius);
} }
e2d::ColliderCircle::ColliderCircle(Node * node) e2d::ColliderCircle::ColliderCircle(Node * node)
: m_pD2dCircle(nullptr) : _pD2dCircle(nullptr)
{ {
double minSide = min(node->getRealWidth(), node->getRealHeight()); double minSide = min(node->getRealWidth(), node->getRealHeight());
this->setCircle( this->setCircle(
@ -27,12 +27,12 @@ e2d::ColliderCircle::ColliderCircle(Node * node)
e2d::ColliderCircle::~ColliderCircle() e2d::ColliderCircle::~ColliderCircle()
{ {
SafeReleaseInterface(&m_pD2dCircle); SafeReleaseInterface(&_pD2dCircle);
} }
void e2d::ColliderCircle::setCircle(Point center, double radius) void e2d::ColliderCircle::setCircle(Point center, double radius)
{ {
SafeReleaseInterface(&m_pD2dCircle); SafeReleaseInterface(&_pD2dCircle);
Renderer::getID2D1Factory()->CreateEllipseGeometry( Renderer::getID2D1Factory()->CreateEllipseGeometry(
D2D1::Ellipse( D2D1::Ellipse(
@ -41,19 +41,19 @@ void e2d::ColliderCircle::setCircle(Point center, double radius)
static_cast<float>(center.y)), static_cast<float>(center.y)),
static_cast<float>(radius), static_cast<float>(radius),
static_cast<float>(radius)), static_cast<float>(radius)),
&m_pD2dCircle &_pD2dCircle
); );
} }
void e2d::ColliderCircle::_resize() 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( this->setCircle(
Point( Point(
m_pParentNode->getRealWidth() / 2, _pParentNode->getRealWidth() / 2,
m_pParentNode->getRealHeight() / 2 _pParentNode->getRealHeight() / 2
), ),
minSide / 2 minSide / 2
); );
@ -62,5 +62,5 @@ void e2d::ColliderCircle::_resize()
ID2D1EllipseGeometry * e2d::ColliderCircle::getD2dGeometry() const ID2D1EllipseGeometry * e2d::ColliderCircle::getD2dGeometry() const
{ {
return m_pD2dCircle; return _pD2dCircle;
} }

View File

@ -2,18 +2,18 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::ColliderEllipse::ColliderEllipse() e2d::ColliderEllipse::ColliderEllipse()
: m_pD2dEllipse(nullptr) : _pD2dEllipse(nullptr)
{ {
} }
e2d::ColliderEllipse::ColliderEllipse(Point center, double radiusX, double radiusY) e2d::ColliderEllipse::ColliderEllipse(Point center, double radiusX, double radiusY)
: m_pD2dEllipse(nullptr) : _pD2dEllipse(nullptr)
{ {
this->setEllipse(center, radiusX, radiusY); this->setEllipse(center, radiusX, radiusY);
} }
e2d::ColliderEllipse::ColliderEllipse(Node * node) e2d::ColliderEllipse::ColliderEllipse(Node * node)
: m_pD2dEllipse(nullptr) : _pD2dEllipse(nullptr)
{ {
this->setEllipse( this->setEllipse(
Point( Point(
@ -27,12 +27,12 @@ e2d::ColliderEllipse::ColliderEllipse(Node * node)
e2d::ColliderEllipse::~ColliderEllipse() e2d::ColliderEllipse::~ColliderEllipse()
{ {
SafeReleaseInterface(&m_pD2dEllipse); SafeReleaseInterface(&_pD2dEllipse);
} }
void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiusY) void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiusY)
{ {
SafeReleaseInterface(&m_pD2dEllipse); SafeReleaseInterface(&_pD2dEllipse);
Renderer::getID2D1Factory()->CreateEllipseGeometry( Renderer::getID2D1Factory()->CreateEllipseGeometry(
D2D1::Ellipse( D2D1::Ellipse(
@ -41,26 +41,26 @@ void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiu
static_cast<float>(center.y)), static_cast<float>(center.y)),
static_cast<float>(radiusX), static_cast<float>(radiusX),
static_cast<float>(radiusY)), static_cast<float>(radiusY)),
&m_pD2dEllipse &_pD2dEllipse
); );
} }
void e2d::ColliderEllipse::_resize() void e2d::ColliderEllipse::_resize()
{ {
if (m_pParentNode && m_bEnable) if (_pParentNode && _bEnable)
{ {
this->setEllipse( this->setEllipse(
Point( Point(
m_pParentNode->getWidth() / 2, _pParentNode->getWidth() / 2,
m_pParentNode->getHeight() / 2 _pParentNode->getHeight() / 2
), ),
m_pParentNode->getWidth() / 2, _pParentNode->getWidth() / 2,
m_pParentNode->getHeight() / 2 _pParentNode->getHeight() / 2
); );
} }
} }
ID2D1EllipseGeometry * e2d::ColliderEllipse::getD2dGeometry() const ID2D1EllipseGeometry * e2d::ColliderEllipse::getD2dGeometry() const
{ {
return m_pD2dEllipse; return _pD2dEllipse;
} }

View File

@ -2,30 +2,30 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::ColliderRect::ColliderRect() e2d::ColliderRect::ColliderRect()
: m_pD2dRectangle(nullptr) : _pD2dRectangle(nullptr)
{ {
} }
e2d::ColliderRect::ColliderRect(double x, double y, double width, double height) e2d::ColliderRect::ColliderRect(double x, double y, double width, double height)
: m_pD2dRectangle(nullptr) : _pD2dRectangle(nullptr)
{ {
this->setRect(x, y, x + width, y + height); this->setRect(x, y, x + width, y + height);
} }
e2d::ColliderRect::ColliderRect(Node * node) e2d::ColliderRect::ColliderRect(Node * node)
: m_pD2dRectangle(nullptr) : _pD2dRectangle(nullptr)
{ {
this->setRect(0, 0, node->getRealWidth(), node->getRealHeight()); this->setRect(0, 0, node->getRealWidth(), node->getRealHeight());
} }
e2d::ColliderRect::~ColliderRect() e2d::ColliderRect::~ColliderRect()
{ {
SafeReleaseInterface(&m_pD2dRectangle); SafeReleaseInterface(&_pD2dRectangle);
} }
void e2d::ColliderRect::setRect(double left, double top, double right, double bottom) void e2d::ColliderRect::setRect(double left, double top, double right, double bottom)
{ {
SafeReleaseInterface(&m_pD2dRectangle); SafeReleaseInterface(&_pD2dRectangle);
Renderer::getID2D1Factory()->CreateRectangleGeometry( Renderer::getID2D1Factory()->CreateRectangleGeometry(
D2D1::RectF( 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>(top),
static_cast<float>(right), static_cast<float>(right),
static_cast<float>(bottom)), static_cast<float>(bottom)),
&m_pD2dRectangle &_pD2dRectangle
); );
} }
void e2d::ColliderRect::_resize() 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 ID2D1RectangleGeometry * e2d::ColliderRect::getD2dGeometry() const
{ {
return m_pD2dRectangle; return _pD2dRectangle;
} }

View File

@ -1,28 +1,28 @@
#include "..\e2dcommon.h" #include "..\e2dcommon.h"
e2d::Function::Function() e2d::Function::Function()
: m_func(nullptr) : _func(nullptr)
{} {}
e2d::Function::Function(std::nullptr_t) e2d::Function::Function(std::nullptr_t)
: m_func(nullptr) : _func(nullptr)
{ {
} }
e2d::Function::Function(std::function<void()> func) e2d::Function::Function(std::function<void()> func)
: m_func(func) : _func(func)
{ {
} }
void e2d::Function::operator()(void) const void e2d::Function::operator()(void) const
{ {
if (m_func) if (_func)
{ {
m_func(); _func();
} }
} }
e2d::Function::operator bool() const e2d::Function::operator bool() const
{ {
return static_cast<bool>(m_func); return static_cast<bool>(_func);
} }

View File

@ -6,35 +6,35 @@ static std::map<int, ID2D1Bitmap*> s_mBitmapsFromResource;
e2d::Image::Image() e2d::Image::Image()
: m_pBitmap(nullptr) : _pBitmap(nullptr)
, m_fSourceCropX(0) , _fSourceCropX(0)
, m_fSourceCropY(0) , _fSourceCropY(0)
, m_fSourceCropWidth(0) , _fSourceCropWidth(0)
, m_fSourceCropHeight(0) , _fSourceCropHeight(0)
{ {
} }
e2d::Image::Image(const String& filePath) e2d::Image::Image(const String& filePath)
: m_pBitmap(nullptr) : _pBitmap(nullptr)
{ {
this->open(filePath); this->open(filePath);
} }
e2d::Image::Image(int resNameId, const String& resType) e2d::Image::Image(int resNameId, const String& resType)
: m_pBitmap(nullptr) : _pBitmap(nullptr)
{ {
this->open(resNameId, resType); this->open(resNameId, resType);
} }
e2d::Image::Image(const String& filePath, double cropX, double cropY, double cropWidth, double cropHeight) e2d::Image::Image(const String& filePath, double cropX, double cropY, double cropWidth, double cropHeight)
: m_pBitmap(nullptr) : _pBitmap(nullptr)
{ {
this->open(filePath); this->open(filePath);
this->crop(cropX, cropY, cropWidth, cropHeight); this->crop(cropX, cropY, cropWidth, cropHeight);
} }
e2d::Image::Image(int resNameId, const String& resType, double cropX, double cropY, double cropWidth, double 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->open(resNameId, resType);
this->crop(cropX, cropY, cropWidth, cropHeight); this->crop(cropX, cropY, cropWidth, cropHeight);
@ -57,10 +57,10 @@ bool e2d::Image::open(const String& filePath)
return false; return false;
} }
m_pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode()); _pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode());
m_fSourceCropX = m_fSourceCropY = 0; _fSourceCropX = _fSourceCropY = 0;
m_fSourceCropWidth = m_pBitmap->GetSize().width; _fSourceCropWidth = _pBitmap->GetSize().width;
m_fSourceCropHeight = m_pBitmap->GetSize().height; _fSourceCropHeight = _pBitmap->GetSize().height;
return true; return true;
} }
@ -72,44 +72,44 @@ bool e2d::Image::open(int resNameId, const String& resType)
return false; return false;
} }
m_pBitmap = s_mBitmapsFromResource.at(resNameId); _pBitmap = s_mBitmapsFromResource.at(resNameId);
m_fSourceCropX = m_fSourceCropY = 0; _fSourceCropX = _fSourceCropY = 0;
m_fSourceCropWidth = m_pBitmap->GetSize().width; _fSourceCropWidth = _pBitmap->GetSize().width;
m_fSourceCropHeight = m_pBitmap->GetSize().height; _fSourceCropHeight = _pBitmap->GetSize().height;
return true; return true;
} }
void e2d::Image::crop(double x, double y, double width, double height) 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()); _fSourceCropX = min(max(x, 0), this->getSourceWidth());
m_fSourceCropY = min(max(y, 0), this->getSourceHeight()); _fSourceCropY = min(max(y, 0), this->getSourceHeight());
m_fSourceCropWidth = min(max(width, 0), this->getSourceWidth() - m_fSourceCropX); _fSourceCropWidth = min(max(width, 0), this->getSourceWidth() - _fSourceCropX);
m_fSourceCropHeight = min(max(height, 0), this->getSourceHeight() - m_fSourceCropY); _fSourceCropHeight = min(max(height, 0), this->getSourceHeight() - _fSourceCropY);
} }
} }
double e2d::Image::getWidth() const double e2d::Image::getWidth() const
{ {
return m_fSourceCropWidth; return _fSourceCropWidth;
} }
double e2d::Image::getHeight() const double e2d::Image::getHeight() const
{ {
return m_fSourceCropHeight; return _fSourceCropHeight;
} }
e2d::Size e2d::Image::getSize() const e2d::Size e2d::Image::getSize() const
{ {
return Size(m_fSourceCropWidth, m_fSourceCropHeight); return Size(_fSourceCropWidth, _fSourceCropHeight);
} }
double e2d::Image::getSourceWidth() const double e2d::Image::getSourceWidth() const
{ {
if (m_pBitmap) if (_pBitmap)
{ {
return m_pBitmap->GetSize().width; return _pBitmap->GetSize().width;
} }
else else
{ {
@ -119,9 +119,9 @@ double e2d::Image::getSourceWidth() const
double e2d::Image::getSourceHeight() const double e2d::Image::getSourceHeight() const
{ {
if (m_pBitmap) if (_pBitmap)
{ {
return m_pBitmap->GetSize().height; return _pBitmap->GetSize().height;
} }
else else
{ {
@ -131,7 +131,7 @@ double e2d::Image::getSourceHeight() const
e2d::Size e2d::Image::getSourceSize() const e2d::Size e2d::Image::getSourceSize() const
{ {
if (m_pBitmap) if (_pBitmap)
{ {
return Size(getSourceWidth(), getSourceHeight()); return Size(getSourceWidth(), getSourceHeight());
} }
@ -143,17 +143,17 @@ e2d::Size e2d::Image::getSourceSize() const
double e2d::Image::getCropX() const double e2d::Image::getCropX() const
{ {
return m_fSourceCropX; return _fSourceCropX;
} }
double e2d::Image::getCropY() const double e2d::Image::getCropY() const
{ {
return m_fSourceCropY; return _fSourceCropY;
} }
e2d::Point e2d::Image::getCropPos() const e2d::Point e2d::Image::getCropPos() const
{ {
return Point(m_fSourceCropX, m_fSourceCropY); return Point(_fSourceCropX, _fSourceCropY);
} }
bool e2d::Image::preload(const String& fileName) bool e2d::Image::preload(const String& fileName)
@ -376,5 +376,5 @@ void e2d::Image::clearCache()
ID2D1Bitmap * e2d::Image::getBitmap() ID2D1Bitmap * e2d::Image::getBitmap()
{ {
return m_pBitmap; return _pBitmap;
} }

View File

@ -2,7 +2,7 @@
#include "..\e2dmanager.h" #include "..\e2dmanager.h"
e2d::Object::Object() e2d::Object::Object()
: m_nRefCount(0) : _nRefCount(0)
{ {
ObjectManager::__add(this); ObjectManager::__add(this);
} }
@ -14,18 +14,18 @@ e2d::Object::~Object()
// 引用计数加一 // 引用计数加一
void e2d::Object::retain() void e2d::Object::retain()
{ {
m_nRefCount++; _nRefCount++;
} }
// 引用计数减一 // 引用计数减一
void e2d::Object::release() void e2d::Object::release()
{ {
m_nRefCount--; _nRefCount--;
// 通知对象管理池刷新 // 通知对象管理池刷新
ObjectManager::flush(); ObjectManager::flush();
} }
int e2d::Object::getRefCount() const int e2d::Object::getRefCount() const
{ {
return m_nRefCount; return _nRefCount;
} }

View File

@ -3,14 +3,14 @@
#include "..\e2dmanager.h" #include "..\e2dmanager.h"
e2d::Scene::Scene() e2d::Scene::Scene()
: m_bWillSave(true) : _bWillSave(true)
, m_bAutoUpdate(true) , _bAutoUpdate(true)
, m_bSortNeeded(false) , _bSortNeeded(false)
, m_bColliderVisiable(false) , _bColliderVisiable(false)
, m_pRoot(new Node()) , _pRoot(new Node())
{ {
m_pRoot->retain(); _pRoot->retain();
m_pRoot->_setParentScene(this); _pRoot->_setParentScene(this);
} }
e2d::Scene::~Scene() e2d::Scene::~Scene()
@ -19,36 +19,36 @@ e2d::Scene::~Scene()
void e2d::Scene::_render() void e2d::Scene::_render()
{ {
m_pRoot->_render(); _pRoot->_render();
if (m_bColliderVisiable) if (_bColliderVisiable)
{ {
// 恢复矩阵转换 // 恢复矩阵转换
Renderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); Renderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
// 绘制所有几何图形 // 绘制所有几何图形
m_pRoot->_drawCollider(); _pRoot->_drawCollider();
} }
} }
void e2d::Scene::_update() void e2d::Scene::_update()
{ {
// 执行 onUpdate 函数 // 执行 onUpdate 函数
if (m_bAutoUpdate) if (_bAutoUpdate)
{ {
this->onUpdate(); this->onUpdate();
} }
// 更新根节点 // 更新根节点
m_pRoot->_update(); _pRoot->_update();
} }
void e2d::Scene::setAutoUpdate(bool bAutoUpdate) void e2d::Scene::setAutoUpdate(bool bAutoUpdate)
{ {
m_bAutoUpdate = bAutoUpdate; _bAutoUpdate = bAutoUpdate;
} }
void e2d::Scene::add(Node * child, int order /* = 0 */) void e2d::Scene::add(Node * child, int order /* = 0 */)
{ {
m_pRoot->addChild(child, order); _pRoot->addChild(child, order);
} }
#ifdef HIGHER_THAN_VS2012 #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) 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 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 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 std::vector<e2d::Node*> e2d::Scene::getAll() const
{ {
return m_pRoot->getAllChildren(); return _pRoot->getAllChildren();
} }
e2d::Node * e2d::Scene::getRoot() const e2d::Node * e2d::Scene::getRoot() const
{ {
return m_pRoot; return _pRoot;
} }
void e2d::Scene::showCollider(bool visiable) void e2d::Scene::showCollider(bool visiable)
{ {
m_bColliderVisiable = visiable; _bColliderVisiable = visiable;
} }
void e2d::Scene::destroy() void e2d::Scene::destroy()
{ {
SafeRelease(&m_pRoot); SafeRelease(&_pRoot);
} }

View File

@ -5,72 +5,72 @@
e2d::String::String() e2d::String::String()
: m_str(L"") : _str(L"")
{ {
} }
e2d::String::String(const wchar_t *str) e2d::String::String(const wchar_t *str)
: m_str(str) : _str(str)
{ {
} }
e2d::String::String(const char *cstr) 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) 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) e2d::String::String(const e2d::String &str)
: m_str(str.m_str) : _str(str._str)
{ {
} }
e2d::String::~String() e2d::String::~String()
{ {
m_str.clear(); _str.clear();
} }
e2d::String &e2d::String::operator=(const wchar_t *str) e2d::String &e2d::String::operator=(const wchar_t *str)
{ {
m_str = str; _str = str;
return (*this); return (*this);
} }
e2d::String & e2d::String::operator=(const char *cstr) 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); return (*this);
} }
e2d::String e2d::String::parse(int value) e2d::String e2d::String::parse(int value)
{ {
String tmp; String tmp;
tmp.m_str = std::to_wstring(value); tmp._str = std::to_wstring(value);
return std::move(tmp); return std::move(tmp);
} }
e2d::String e2d::String::parse(unsigned int value) e2d::String e2d::String::parse(unsigned int value)
{ {
String tmp; String tmp;
tmp.m_str = std::to_wstring(value); tmp._str = std::to_wstring(value);
return std::move(tmp); return std::move(tmp);
} }
e2d::String e2d::String::parse(float value) e2d::String e2d::String::parse(float value)
{ {
String tmp; String tmp;
tmp.m_str = std::to_wstring(value); tmp._str = std::to_wstring(value);
return std::move(tmp); return std::move(tmp);
} }
e2d::String e2d::String::parse(double value) e2d::String e2d::String::parse(double value)
{ {
String tmp; String tmp;
tmp.m_str = std::to_wstring(value); tmp._str = std::to_wstring(value);
return std::move(tmp); return std::move(tmp);
} }
@ -81,11 +81,11 @@ e2d::String e2d::String::format(const char * format, ...)
va_list marker = NULL; va_list marker = NULL;
va_start(marker, format); 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); 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_list marker = NULL;
va_start(marker, format); 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); 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) 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) e2d::String & e2d::String::operator=(const String &str)
{ {
m_str = str.m_str; _str = str._str;
return (*this); return (*this);
} }
@ -133,7 +133,7 @@ bool e2d::String::operator==(const wchar_t *str)
{ {
if (str) if (str)
{ {
return (m_str.compare(str) == 0); return (_str.compare(str) == 0);
} }
else else
{ {
@ -146,7 +146,7 @@ bool e2d::String::operator==(const char *str)
if (str) if (str)
{ {
String temp(str); String temp(str);
return (m_str == temp.m_str); return (_str == temp._str);
} }
else else
{ {
@ -156,14 +156,14 @@ bool e2d::String::operator==(const char *str)
bool e2d::String::operator ==(const e2d::String &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) bool e2d::String::operator!=(const wchar_t *str)
{ {
if (str) if (str)
{ {
return (m_str.compare(str) != 0); return (_str.compare(str) != 0);
} }
else else
{ {
@ -176,7 +176,7 @@ bool e2d::String::operator!=(const char *str)
if (str) if (str)
{ {
String temp(str); String temp(str);
return (m_str != temp.m_str); return (_str != temp._str);
} }
else else
{ {
@ -186,114 +186,114 @@ bool e2d::String::operator!=(const char *str)
bool e2d::String::operator!=(const e2d::String &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) 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) e2d::String e2d::String::operator+(const wchar_t *str)
{ {
String temp; String temp;
temp.m_str = m_str + str; temp._str = _str + str;
return std::move(temp); return std::move(temp);
} }
e2d::String e2d::String::operator+(const char *str) e2d::String e2d::String::operator+(const char *str)
{ {
String temp; 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); return std::move(temp);
} }
e2d::String e2d::String::operator+(const e2d::String &str) e2d::String e2d::String::operator+(const e2d::String &str)
{ {
String temp; String temp;
temp.m_str = m_str + str.m_str; temp._str = _str + str._str;
return std::move(temp); return std::move(temp);
} }
e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2) e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2)
{ {
String temp; String temp;
temp.m_str = str1 + str2.m_str; temp._str = str1 + str2._str;
return std::move(temp); return std::move(temp);
} }
e2d::String e2d::operator+(const char *str1, const String &str2) e2d::String e2d::operator+(const char *str1, const String &str2)
{ {
String temp; 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); return std::move(temp);
} }
e2d::String & e2d::String::operator+=(const wchar_t *str) e2d::String & e2d::String::operator+=(const wchar_t *str)
{ {
m_str += str; _str += str;
return (*this); return (*this);
} }
e2d::String & e2d::String::operator+=(const char *str) 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); return (*this);
} }
e2d::String & e2d::String::operator+=(const String &str) e2d::String & e2d::String::operator+=(const String &str)
{ {
m_str += str.m_str; _str += str._str;
return (*this); return (*this);
} }
bool e2d::String::operator>(const String &str) const 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 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 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 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) e2d::String & e2d::String::operator<<(const String &str)
{ {
m_str += str.m_str; _str += str._str;
return (*this); return (*this);
} }
e2d::String & e2d::String::operator<<(const wchar_t *str) e2d::String & e2d::String::operator<<(const wchar_t *str)
{ {
m_str += str; _str += str;
return (*this); return (*this);
} }
e2d::String & e2d::String::operator<<(wchar_t *str) e2d::String & e2d::String::operator<<(wchar_t *str)
{ {
m_str += str; _str += str;
return (*this); return (*this);
} }
e2d::String & e2d::String::operator<<(const char * cstr) 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); return (*this);
} }
e2d::String & e2d::String::operator<<(char * cstr) 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); return (*this);
} }
@ -323,22 +323,22 @@ e2d::String & e2d::String::operator<<(double value)
e2d::String::operator const wchar_t*() const e2d::String::operator const wchar_t*() const
{ {
return m_str.c_str(); return _str.c_str();
} }
e2d::String::operator wchar_t*() const 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 bool e2d::String::isEmpty() const
{ {
return m_str.empty(); return _str.empty();
} }
int e2d::String::getLength() const int e2d::String::getLength() const
{ {
return static_cast<int>(m_str.size()); return static_cast<int>(_str.size());
} }
unsigned int e2d::String::getHashCode() const unsigned int e2d::String::getHashCode() const
@ -348,25 +348,25 @@ unsigned int e2d::String::getHashCode() const
for (int i = 0; i < getLength(); i++) for (int i = 0; i < getLength(); i++)
{ {
hash *= 16777619; hash *= 16777619;
hash ^= (unsigned int)towupper(m_str[i]); hash ^= (unsigned int)towupper(_str[i]);
} }
return hash; return hash;
} }
std::wstring e2d::String::getWString() const std::wstring e2d::String::getWString() const
{ {
return m_str; return _str;
} }
std::string e2d::String::getCString() const 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); return std::move(str);
} }
int e2d::String::compare(const String & str) const 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 e2d::String e2d::String::toUpper() const
@ -395,7 +395,7 @@ int e2d::String::toInt() const
{ {
return 0; return 0;
} }
return std::stoi(m_str, 0, 10); return std::stoi(_str, 0, 10);
} }
double e2d::String::toDouble() const double e2d::String::toDouble() const
@ -404,7 +404,7 @@ double e2d::String::toDouble() const
{ {
return 0.0; return 0.0;
} }
return std::stod(m_str, 0); return std::stod(_str, 0);
} }
bool e2d::String::toBool() const bool e2d::String::toBool() const
@ -414,7 +414,7 @@ bool e2d::String::toBool() const
return false; 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; return false;
} }
@ -434,37 +434,37 @@ e2d::String e2d::String::subtract(int offset, int count) const
if (count < 0 || (offset + count) > length) if (count < 0 || (offset + count) > length)
count = length - offset; count = length - offset;
tmp.m_str = m_str.substr(offset, count); tmp._str = _str.substr(offset, count);
return std::move(tmp); return std::move(tmp);
} }
void e2d::String::insert(const String & str, int pos) 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) void e2d::String::replace(const String & from, const String & to)
{ {
if (from.m_str.empty()) if (from._str.empty())
return; return;
size_t start_pos = 0; 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); _str.replace(start_pos, from._str.length(), to);
start_pos += to.m_str.length(); start_pos += to._str.length();
} }
} }
void e2d::String::erase(int offset, int count) 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 int e2d::String::find(const String & str, int offset) const
{ {
size_t index; 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; return -1;
} }
@ -476,24 +476,24 @@ int e2d::String::find(const String & str, int offset) const
void e2d::String::clear() void e2d::String::clear()
{ {
m_str.clear(); _str.clear();
} }
std::wostream & e2d::operator<<(std::wostream &cout, const String &str) std::wostream & e2d::operator<<(std::wostream &cout, const String &str)
{ {
cout << str.m_str; cout << str._str;
return cout; return cout;
} }
std::wistream & e2d::operator>>(std::wistream &cin, String &str) std::wistream & e2d::operator>>(std::wistream &cin, String &str)
{ {
cin >> str.m_str; cin >> str._str;
return cin; return cin;
} }
std::ostream & e2d::operator<<(std::ostream &cout, const String &str) 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; cout << cstr;
return cout; return cout;
} }
@ -502,6 +502,6 @@ std::istream & e2d::operator>>(std::istream &cin, String &str)
{ {
std::string temp; std::string temp;
cin >> 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; return cin;
} }

View File

@ -19,7 +19,7 @@ void e2d::ActionManager::__update()
{ {
// ¶¯×÷ÒѾ­½áÊø // ¶¯×÷ÒѾ­½áÊø
action->release(); action->release();
action->m_pTarget = nullptr; action->_pTarget = nullptr;
s_vRunningActions.erase(s_vRunningActions.begin() + i); s_vRunningActions.erase(s_vRunningActions.begin() + i);
} }
else 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) s_vActions.push_back(action);
{
if (action == pAction)
{
WARN_IF(true, "ActionManager::add Failed!The action is already added.");
return;
}
}
s_vActions.push_back(pAction);
} }
} }
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); 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 (target)
if (pAction)
{
pAction->startWithTarget(pTargetNode);
pAction->retain();
s_vRunningActions.push_back(pAction);
}
}
void e2d::ActionManager::__resumeAllBindedWith(Node * pTargetNode)
{
if (pTargetNode)
{ {
for (auto action : s_vRunningActions) for (auto action : s_vRunningActions)
{ {
if (action->getTarget() == pTargetNode) if (action->getTarget() == target)
{ {
action->resume(); 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) for (auto action : s_vRunningActions)
{ {
if (action->getTarget() == pTargetNode) if (action->getTarget() == target)
{ {
action->pause(); 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) for (auto action : s_vRunningActions)
{ {
if (action->getTarget() == pTargetNode) if (action->getTarget() == target)
{ {
action->stop(); 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) void e2d::ActionManager::resume(const String& strActionName)
{ {
for (auto action : s_vRunningActions) 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();) for (size_t i = 0; i < s_vRunningActions.size();)
{ {
auto a = s_vRunningActions[i]; auto a = s_vRunningActions[i];
if (a->getTarget() == pTargetNode) if (a->getTarget() == target)
{ {
SafeRelease(&a); SafeRelease(&a);
s_vRunningActions.erase(s_vRunningActions.begin() + i); s_vRunningActions.erase(s_vRunningActions.begin() + i);

View File

@ -81,7 +81,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
if (!s_bCollisionEnable) if (!s_bCollisionEnable)
return; return;
Node* pActiveNode = pActiveCollider->m_pParentNode; Node* pActiveNode = pActiveCollider->_pParentNode;
if (pActiveNode) if (pActiveNode)
{ {
// 获取节点所在场景 // 获取节点所在场景
@ -96,7 +96,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
continue; continue;
// 获取被碰撞节点 // 获取被碰撞节点
Node* pPassiveNode = pPassiveCollider->m_pParentNode; Node* pPassiveNode = pPassiveCollider->_pParentNode;
// 判断两节点是否处于同一场景中 // 判断两节点是否处于同一场景中
if (pPassiveNode && if (pPassiveNode &&
pPassiveNode->getParentScene() == pCurrentScene) pPassiveNode->getParentScene() == pCurrentScene)
@ -105,7 +105,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
auto IsCollideWith = [](Node * active, Node * passive) -> bool auto IsCollideWith = [](Node * active, Node * passive) -> bool
{ {
unsigned int hash = passive->getHashName(); unsigned int hash = passive->getHashName();
for (auto collider : active->m_vColliders) for (auto collider : active->_vColliders)
if (collider == hash) if (collider == hash)
return true; return true;
return false; return false;
@ -206,11 +206,11 @@ e2d::Node * e2d::ColliderManager::getPassiveNode()
return s_pPassiveNode; 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; return s_pPassiveNode;
if (s_pPassiveNode == pNode) if (s_pPassiveNode == node)
return s_pActiveNode; return s_pActiveNode;
return nullptr; return nullptr;
} }
@ -228,7 +228,7 @@ void e2d::ColliderManager::__addCollider(Collider * pCollider)
{ {
if (pCollider) if (pCollider)
{ {
if (pCollider->m_pParentNode) if (pCollider->_pParentNode)
{ {
WARN_IF(true, "ColliderManager::__add Failed! The shape is already added."); WARN_IF(true, "ColliderManager::__add Failed! The shape is already added.");
return; return;

View File

@ -2,7 +2,7 @@
#include "..\e2dbase.h" #include "..\e2dbase.h"
// ObjectManager 释放池的实现机制: // ObjectManager 释放池的实现机制:
// Object 类中的引用计数(m_nRefCount在一定程度上保证了指针的使用安全 // Object 类中的引用计数(_nRefCount在一定程度上保证了指针的使用安全
// 它记录了对象被使用的次数,当计数为 0 时ObjectManager 会自动释放这个对象 // 它记录了对象被使用的次数,当计数为 0 时ObjectManager 会自动释放这个对象
// 所有的 Object 对象都应在被使用时(例如 Text 添加到了场景中) // 所有的 Object 对象都应在被使用时(例如 Text 添加到了场景中)
// 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数 // 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数
@ -17,15 +17,12 @@ void e2d::ObjectManager::__update()
if (!s_bNotifyed) return; if (!s_bNotifyed) return;
s_bNotifyed = false; s_bNotifyed = false;
// 循环遍历容器中的所有对象
for (auto iter = s_vObjectPool.begin(); iter != s_vObjectPool.end();) for (auto iter = s_vObjectPool.begin(); iter != s_vObjectPool.end();)
{ {
if ((*iter)->getRefCount() <= 0) if ((*iter)->getRefCount() <= 0)
{ {
// 若对象的引用的计数小于等于 0, 释放该对象
(*iter)->destroy(); (*iter)->destroy();
delete (*iter); delete (*iter);
// 从释放池中删除该对象
iter = s_vObjectPool.erase(iter); iter = s_vObjectPool.erase(iter);
} }
else else

View File

@ -31,7 +31,7 @@ void e2d::SceneManager::enter(Scene * scene, TransitionBase * transition /* = nu
if (s_pCurrScene) 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) if (s_pCurrScene)
{ {
s_pCurrScene->m_bWillSave = false; s_pCurrScene->_bWillSave = false;
} }
// 设置切换场景动画 // 设置切换场景动画
@ -120,7 +120,7 @@ void e2d::SceneManager::__update()
s_pCurrScene->onExit(); s_pCurrScene->onExit();
// 若要保存当前场景,把它放入栈中 // 若要保存当前场景,把它放入栈中
if (s_pCurrScene->m_bWillSave) if (s_pCurrScene->_bWillSave)
{ {
s_SceneStack.push(s_pCurrScene); s_SceneStack.push(s_pCurrScene);
} }

View File

@ -5,40 +5,40 @@
e2d::Button::Button() e2d::Button::Button()
: m_Callback(nullptr) : _Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL) , _eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , _bEnable(true)
, m_bIsSelected(false) , _bIsSelected(false)
, m_pNormal(nullptr) , _pNormal(nullptr)
, m_pMouseover(nullptr) , _pMouseover(nullptr)
, m_pSelected(nullptr) , _pSelected(nullptr)
, m_pDisabled(nullptr) , _pDisabled(nullptr)
{ {
} }
e2d::Button::Button(Node * normal, const Function& func) e2d::Button::Button(Node * normal, const Function& func)
: m_Callback(nullptr) : _Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL) , _eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , _bEnable(true)
, m_bIsSelected(false) , _bIsSelected(false)
, m_pNormal(nullptr) , _pNormal(nullptr)
, m_pMouseover(nullptr) , _pMouseover(nullptr)
, m_pSelected(nullptr) , _pSelected(nullptr)
, m_pDisabled(nullptr) , _pDisabled(nullptr)
{ {
this->setNormal(normal); this->setNormal(normal);
this->setClickFunc(func); this->setClickFunc(func);
} }
e2d::Button::Button(Node * normal, Node * selected, const Function& func) e2d::Button::Button(Node * normal, Node * selected, const Function& func)
: m_Callback(nullptr) : _Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL) , _eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , _bEnable(true)
, m_bIsSelected(false) , _bIsSelected(false)
, m_pNormal(nullptr) , _pNormal(nullptr)
, m_pMouseover(nullptr) , _pMouseover(nullptr)
, m_pSelected(nullptr) , _pSelected(nullptr)
, m_pDisabled(nullptr) , _pDisabled(nullptr)
{ {
this->setNormal(normal); this->setNormal(normal);
this->setSelected(selected); 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) e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func)
: m_Callback(nullptr) : _Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL) , _eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , _bEnable(true)
, m_bIsSelected(false) , _bIsSelected(false)
, m_pNormal(nullptr) , _pNormal(nullptr)
, m_pMouseover(nullptr) , _pMouseover(nullptr)
, m_pSelected(nullptr) , _pSelected(nullptr)
, m_pDisabled(nullptr) , _pDisabled(nullptr)
{ {
this->setNormal(normal); this->setNormal(normal);
this->setMouseOver(mouseover); 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) e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func)
: m_Callback(nullptr) : _Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL) , _eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , _bEnable(true)
, m_bIsSelected(false) , _bIsSelected(false)
, m_pNormal(nullptr) , _pNormal(nullptr)
, m_pMouseover(nullptr) , _pMouseover(nullptr)
, m_pSelected(nullptr) , _pSelected(nullptr)
, m_pDisabled(nullptr) , _pDisabled(nullptr)
{ {
this->setNormal(normal); this->setNormal(normal);
this->setMouseOver(mouseover); this->setMouseOver(mouseover);
@ -80,17 +80,17 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * dis
bool e2d::Button::isEnable() const bool e2d::Button::isEnable() const
{ {
return m_bEnable; return _bEnable;
} }
void e2d::Button::setNormal(Node * normal) 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) if (normal)
@ -98,7 +98,7 @@ void e2d::Button::setNormal(Node * normal)
this->addChild(normal); this->addChild(normal);
this->setSize(normal->getWidth(), normal->getHeight()); this->setSize(normal->getWidth(), normal->getHeight());
} }
m_pNormal = normal; _pNormal = normal;
_updateVisiable(); _updateVisiable();
} }
@ -106,75 +106,75 @@ void e2d::Button::setNormal(Node * normal)
void e2d::Button::setMouseOver(Node * mouseover) 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) if (mouseover)
{ {
this->addChild(mouseover); this->addChild(mouseover);
} }
m_pMouseover = mouseover; _pMouseover = mouseover;
_updateVisiable(); _updateVisiable();
} }
} }
void e2d::Button::setSelected(Node * selected) 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) if (selected)
{ {
this->addChild(selected); this->addChild(selected);
} }
m_pSelected = selected; _pSelected = selected;
_updateVisiable(); _updateVisiable();
} }
} }
void e2d::Button::setDisabled(Node * disabled) 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) if (disabled)
{ {
this->addChild(disabled); this->addChild(disabled);
} }
m_pDisabled = disabled; _pDisabled = disabled;
_updateVisiable(); _updateVisiable();
} }
} }
void e2d::Button::setEnable(bool enable) void e2d::Button::setEnable(bool enable)
{ {
if (m_bEnable != enable) if (_bEnable != enable)
{ {
m_bEnable = enable; _bEnable = enable;
_updateVisiable(); _updateVisiable();
} }
} }
void e2d::Button::setClickFunc(const Function& func) 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() void e2d::Button::onFixedUpdate()
@ -182,40 +182,40 @@ void e2d::Button::onFixedUpdate()
if (SceneManager::isTransitioning()) if (SceneManager::isTransitioning())
return; return;
if (m_bEnable && m_bVisiable && m_pNormal) if (_bEnable && _bVisiable && _pNormal)
{ {
if (Input::isMouseLButtonRelease()) if (Input::isMouseLButtonRelease())
{ {
// 鼠标左键抬起时,判断鼠标坐标是否在按钮内部 // 鼠标左键抬起时,判断鼠标坐标是否在按钮内部
if (m_bIsSelected && if (_bIsSelected &&
m_pNormal->isPointIn(Input::getMousePos())) _pNormal->isPointIn(Input::getMousePos()))
{ {
_runCallback(); _runCallback();
} }
// 标记 m_bIsSelected 为 false // 标记 _bIsSelected 为 false
m_bIsSelected = false; _bIsSelected = false;
} }
if (Input::isMouseLButtonPress()) if (Input::isMouseLButtonPress())
{ {
if (m_pNormal->isPointIn(Input::getMousePos())) if (_pNormal->isPointIn(Input::getMousePos()))
{ {
// 鼠标左键按下,且位于按钮内时,标记 m_bIsSelected 为 true // 鼠标左键按下,且位于按钮内时,标记 _bIsSelected 为 true
m_bIsSelected = true; _bIsSelected = true;
return; return;
} }
} }
if (m_bIsSelected && Input::isMouseLButtonDown()) if (_bIsSelected && Input::isMouseLButtonDown())
{ {
if (m_pNormal->isPointIn(Input::getMousePos())) if (_pNormal->isPointIn(Input::getMousePos()))
{ {
_setState(ButtonState::SELECTED); _setState(ButtonState::SELECTED);
Window::setCursor(Cursor::HAND); Window::setCursor(Cursor::HAND);
return; return;
} }
} }
else if (m_pNormal->isPointIn(Input::getMousePos())) else if (_pNormal->isPointIn(Input::getMousePos()))
{ {
_setState(ButtonState::MOUSEOVER); _setState(ButtonState::MOUSEOVER);
Window::setCursor(Cursor::HAND); Window::setCursor(Cursor::HAND);
@ -225,7 +225,7 @@ void e2d::Button::onFixedUpdate()
_setState(ButtonState::NORMAL); _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); Window::setCursor(Cursor::NO);
} }
@ -233,52 +233,52 @@ void e2d::Button::onFixedUpdate()
void e2d::Button::_setState(ButtonState state) void e2d::Button::_setState(ButtonState state)
{ {
if (m_eBtnState != state) if (_eBtnState != state)
{ {
m_eBtnState = state; _eBtnState = state;
_updateVisiable(); _updateVisiable();
} }
} }
void e2d::Button::_updateVisiable() void e2d::Button::_updateVisiable()
{ {
SAFE_SET(m_pNormal, setVisiable, false); SAFE_SET(_pNormal, setVisiable, false);
SAFE_SET(m_pMouseover, setVisiable, false); SAFE_SET(_pMouseover, setVisiable, false);
SAFE_SET(m_pSelected, setVisiable, false); SAFE_SET(_pSelected, setVisiable, false);
SAFE_SET(m_pDisabled, 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 else
{ {
if (m_pNormal) m_pNormal->setVisiable(true); if (_pNormal) _pNormal->setVisiable(true);
} }
} }
else else
{ {
if (m_pDisabled) if (_pDisabled)
{ {
m_pDisabled->setVisiable(true); _pDisabled->setVisiable(true);
} }
else else
{ {
if (m_pNormal) m_pNormal->setVisiable(true); if (_pNormal) _pNormal->setVisiable(true);
} }
} }
} }
void e2d::Button::_runCallback() void e2d::Button::_runCallback()
{ {
if (m_Callback) if (_Callback)
{ {
m_Callback(); _Callback();
} }
} }

View File

@ -2,29 +2,29 @@
e2d::ButtonToggle::ButtonToggle() e2d::ButtonToggle::ButtonToggle()
: Button() : Button()
, m_bState(true) , _bState(true)
, m_pNormalOn(nullptr) , _pNormalOn(nullptr)
, m_pMouseoverOn(nullptr) , _pMouseoverOn(nullptr)
, m_pSelectedOn(nullptr) , _pSelectedOn(nullptr)
, m_pDisabledOn(nullptr) , _pDisabledOn(nullptr)
, m_pNormalOff(nullptr) , _pNormalOff(nullptr)
, m_pMouseoverOff(nullptr) , _pMouseoverOff(nullptr)
, m_pSelectedOff(nullptr) , _pSelectedOff(nullptr)
, m_pDisabledOff(nullptr) , _pDisabledOff(nullptr)
{ {
} }
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, const Function& func) e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, const Function& func)
: Button() : Button()
, m_bState(true) , _bState(true)
, m_pNormalOn(nullptr) , _pNormalOn(nullptr)
, m_pMouseoverOn(nullptr) , _pMouseoverOn(nullptr)
, m_pSelectedOn(nullptr) , _pSelectedOn(nullptr)
, m_pDisabledOn(nullptr) , _pDisabledOn(nullptr)
, m_pNormalOff(nullptr) , _pNormalOff(nullptr)
, m_pMouseoverOff(nullptr) , _pMouseoverOff(nullptr)
, m_pSelectedOff(nullptr) , _pSelectedOff(nullptr)
, m_pDisabledOff(nullptr) , _pDisabledOff(nullptr)
{ {
this->setNormal(toggleOnNormal); this->setNormal(toggleOnNormal);
this->setNormalOff(toggleOffNormal); 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) e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
: Button() : Button()
, m_bState(true) , _bState(true)
, m_pNormalOn(nullptr) , _pNormalOn(nullptr)
, m_pMouseoverOn(nullptr) , _pMouseoverOn(nullptr)
, m_pSelectedOn(nullptr) , _pSelectedOn(nullptr)
, m_pDisabledOn(nullptr) , _pDisabledOn(nullptr)
, m_pNormalOff(nullptr) , _pNormalOff(nullptr)
, m_pMouseoverOff(nullptr) , _pMouseoverOff(nullptr)
, m_pSelectedOff(nullptr) , _pSelectedOff(nullptr)
, m_pDisabledOff(nullptr) , _pDisabledOff(nullptr)
{ {
this->setNormal(toggleOnNormal); this->setNormal(toggleOnNormal);
this->setNormalOff(toggleOffNormal); 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) e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
: Button() : Button()
, m_bState(true) , _bState(true)
, m_pNormalOn(nullptr) , _pNormalOn(nullptr)
, m_pMouseoverOn(nullptr) , _pMouseoverOn(nullptr)
, m_pSelectedOn(nullptr) , _pSelectedOn(nullptr)
, m_pDisabledOn(nullptr) , _pDisabledOn(nullptr)
, m_pNormalOff(nullptr) , _pNormalOff(nullptr)
, m_pMouseoverOff(nullptr) , _pMouseoverOff(nullptr)
, m_pSelectedOff(nullptr) , _pSelectedOff(nullptr)
, m_pDisabledOff(nullptr) , _pDisabledOff(nullptr)
{ {
this->setNormal(toggleOnNormal); this->setNormal(toggleOnNormal);
this->setNormalOff(toggleOffNormal); 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) e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, const Function& func)
: Button() : Button()
, m_bState(true) , _bState(true)
, m_pNormalOn(nullptr) , _pNormalOn(nullptr)
, m_pMouseoverOn(nullptr) , _pMouseoverOn(nullptr)
, m_pSelectedOn(nullptr) , _pSelectedOn(nullptr)
, m_pDisabledOn(nullptr) , _pDisabledOn(nullptr)
, m_pNormalOff(nullptr) , _pNormalOff(nullptr)
, m_pMouseoverOff(nullptr) , _pMouseoverOff(nullptr)
, m_pSelectedOff(nullptr) , _pSelectedOff(nullptr)
, m_pDisabledOff(nullptr) , _pDisabledOff(nullptr)
{ {
this->setNormal(toggleOnNormal); this->setNormal(toggleOnNormal);
this->setNormalOff(toggleOffNormal); this->setNormalOff(toggleOffNormal);
@ -96,14 +96,14 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
bool e2d::ButtonToggle::getState() const bool e2d::ButtonToggle::getState() const
{ {
return m_bState; return _bState;
} }
void e2d::ButtonToggle::setState(bool bState) void e2d::ButtonToggle::setState(bool bState)
{ {
if (m_bState != bState) if (_bState != bState)
{ {
m_bState = bState; _bState = bState;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
} }
@ -111,12 +111,12 @@ void e2d::ButtonToggle::setState(bool bState)
void e2d::ButtonToggle::setNormal(Node * normal) 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) if (normal)
@ -124,7 +124,7 @@ void e2d::ButtonToggle::setNormal(Node * normal)
this->addChild(normal); this->addChild(normal);
this->setSize(normal->getWidth(), normal->getHeight()); this->setSize(normal->getWidth(), normal->getHeight());
} }
m_pNormalOn = normal; _pNormalOn = normal;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -133,19 +133,19 @@ void e2d::ButtonToggle::setNormal(Node * normal)
void e2d::ButtonToggle::setMouseOver(Node * mouseover) 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) if (mouseover)
{ {
this->addChild(mouseover); this->addChild(mouseover);
} }
m_pMouseoverOn = mouseover; _pMouseoverOn = mouseover;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -154,19 +154,19 @@ void e2d::ButtonToggle::setMouseOver(Node * mouseover)
void e2d::ButtonToggle::setSelected(Node * selected) 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) if (selected)
{ {
this->addChild(selected); this->addChild(selected);
} }
m_pSelectedOn = selected; _pSelectedOn = selected;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -175,19 +175,19 @@ void e2d::ButtonToggle::setSelected(Node * selected)
void e2d::ButtonToggle::setDisabled(Node * disabled) 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) if (disabled)
{ {
this->addChild(disabled); this->addChild(disabled);
} }
m_pDisabledOn = disabled; _pDisabledOn = disabled;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -196,19 +196,19 @@ void e2d::ButtonToggle::setDisabled(Node * disabled)
void e2d::ButtonToggle::setNormalOff(Node * normal) 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) if (normal)
{ {
this->addChild(normal); this->addChild(normal);
} }
m_pNormalOff = normal; _pNormalOff = normal;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -217,19 +217,19 @@ void e2d::ButtonToggle::setNormalOff(Node * normal)
void e2d::ButtonToggle::setMouseOverOff(Node * mouseover) 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) if (mouseover)
{ {
this->addChild(mouseover); this->addChild(mouseover);
} }
m_pMouseoverOff = mouseover; _pMouseoverOff = mouseover;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -238,19 +238,19 @@ void e2d::ButtonToggle::setMouseOverOff(Node * mouseover)
void e2d::ButtonToggle::setSelectedOff(Node * selected) 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) if (selected)
{ {
this->addChild(selected); this->addChild(selected);
} }
m_pSelectedOff = selected; _pSelectedOff = selected;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -259,19 +259,19 @@ void e2d::ButtonToggle::setSelectedOff(Node * selected)
void e2d::ButtonToggle::setDisabledOff(Node * disabled) 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) if (disabled)
{ {
this->addChild(disabled); this->addChild(disabled);
} }
m_pDisabledOff = disabled; _pDisabledOff = disabled;
_updateState(); _updateState();
_updateVisiable(); _updateVisiable();
@ -280,39 +280,39 @@ void e2d::ButtonToggle::setDisabledOff(Node * disabled)
void e2d::ButtonToggle::_updateState() void e2d::ButtonToggle::_updateState()
{ {
if (m_bState) if (_bState)
{ {
m_pNormal = m_pNormalOn; _pNormal = _pNormalOn;
m_pMouseover = m_pMouseoverOn; _pMouseover = _pMouseoverOn;
m_pSelected = m_pSelectedOn; _pSelected = _pSelectedOn;
m_pDisabled = m_pDisabledOn; _pDisabled = _pDisabledOn;
if (m_pNormalOff) m_pNormalOff->setVisiable(false); if (_pNormalOff) _pNormalOff->setVisiable(false);
if (m_pMouseoverOff) m_pMouseoverOff->setVisiable(false); if (_pMouseoverOff) _pMouseoverOff->setVisiable(false);
if (m_pSelectedOff) m_pSelectedOff->setVisiable(false); if (_pSelectedOff) _pSelectedOff->setVisiable(false);
if (m_pDisabledOff) m_pDisabledOff->setVisiable(false); if (_pDisabledOff) _pDisabledOff->setVisiable(false);
} }
else else
{ {
m_pNormal = m_pNormalOff; _pNormal = _pNormalOff;
m_pMouseover = m_pMouseoverOff; _pMouseover = _pMouseoverOff;
m_pSelected = m_pSelectedOff; _pSelected = _pSelectedOff;
m_pDisabled = m_pDisabledOff; _pDisabled = _pDisabledOff;
if (m_pNormalOn) m_pNormalOn->setVisiable(false); if (_pNormalOn) _pNormalOn->setVisiable(false);
if (m_pMouseoverOn) m_pMouseoverOn->setVisiable(false); if (_pMouseoverOn) _pMouseoverOn->setVisiable(false);
if (m_pSelectedOn) m_pSelectedOn->setVisiable(false); if (_pSelectedOn) _pSelectedOn->setVisiable(false);
if (m_pDisabledOn) m_pDisabledOn->setVisiable(false); if (_pDisabledOn) _pDisabledOn->setVisiable(false);
} }
} }
void e2d::ButtonToggle::_runCallback() void e2d::ButtonToggle::_runCallback()
{ {
m_bState = !m_bState; _bState = !_bState;
_updateState(); _updateState();
if (m_Callback) if (_Callback)
{ {
m_Callback(); _Callback();
} }
} }

View File

@ -1,13 +1,13 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::Menu::Menu() e2d::Menu::Menu()
: m_bEnable(true) : _bEnable(true)
{ {
} }
#ifdef HIGHER_THAN_VS2012 #ifdef HIGHER_THAN_VS2012
e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons) e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
: m_bEnable(true) : _bEnable(true)
{ {
for (auto button : vButtons) for (auto button : vButtons)
{ {
@ -18,7 +18,7 @@ e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
#else #else
e2d::Menu::Menu(int number, Button * button1, ...) e2d::Menu::Menu(int number, Button * button1, ...)
: m_bEnable(true) : _bEnable(true)
{ {
Button ** ppButton = &button1; Button ** ppButton = &button1;
@ -33,21 +33,21 @@ e2d::Menu::Menu(int number, Button * button1, ...)
bool e2d::Menu::isEnable() const bool e2d::Menu::isEnable() const
{ {
return m_bEnable; return _bEnable;
} }
size_t e2d::Menu::getButtonCount() const size_t e2d::Menu::getButtonCount() const
{ {
return m_vButtons.size(); return _vButtons.size();
} }
void e2d::Menu::setEnable(bool enable) 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); button->setEnable(enable);
} }
@ -59,14 +59,14 @@ void e2d::Menu::addButton(Button * button)
if (button) if (button)
{ {
this->addChild(button); this->addChild(button);
m_vButtons.push_back(button); _vButtons.push_back(button);
button->setEnable(m_bEnable); button->setEnable(_bEnable);
} }
} }
bool e2d::Menu::removeButton(Button * button) bool e2d::Menu::removeButton(Button * button)
{ {
if (m_vButtons.empty()) if (_vButtons.empty())
{ {
return false; return false;
} }
@ -75,14 +75,14 @@ bool e2d::Menu::removeButton(Button * button)
if (button) if (button)
{ {
size_t size = m_vButtons.size(); size_t size = _vButtons.size();
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
if (m_vButtons[i] == button) if (_vButtons[i] == button)
{ {
// ÒÆ³ý°´Å¥Ç°£¬½«ËüÆôÓà // ÒÆ³ý°´Å¥Ç°£¬½«ËüÆôÓÃ
button->setEnable(true); button->setEnable(true);
m_vButtons.erase(m_vButtons.begin() + i); _vButtons.erase(_vButtons.begin() + i);
return true; return true;
} }
} }

View File

@ -10,31 +10,31 @@ static float s_fDefaultPiovtY = 0;
static bool s_fDefaultColliderEnabled = true; static bool s_fDefaultColliderEnabled = true;
e2d::Node::Node() e2d::Node::Node()
: m_nOrder(0) : _nOrder(0)
, m_fPosX(0) , _fPosX(0)
, m_fPosY(0) , _fPosY(0)
, m_fWidth(0) , _fWidth(0)
, m_fHeight(0) , _fHeight(0)
, m_fScaleX(1.0f) , _fScaleX(1.0f)
, m_fScaleY(1.0f) , _fScaleY(1.0f)
, m_fRotation(0) , _fRotation(0)
, m_fSkewAngleX(0) , _fSkewAngleX(0)
, m_fSkewAngleY(0) , _fSkewAngleY(0)
, m_fDisplayOpacity(1.0f) , _fDisplayOpacity(1.0f)
, m_fRealOpacity(1.0f) , _fRealOpacity(1.0f)
, m_fPivotX(s_fDefaultPiovtX) , _fPivotX(s_fDefaultPiovtX)
, m_fPivotY(s_fDefaultPiovtY) , _fPivotY(s_fDefaultPiovtY)
, m_MatriInitial(D2D1::Matrix3x2F::Identity()) , _MatriInitial(D2D1::Matrix3x2F::Identity())
, m_MatriFinal(D2D1::Matrix3x2F::Identity()) , _MatriFinal(D2D1::Matrix3x2F::Identity())
, m_bVisiable(true) , _bVisiable(true)
, m_pCollider(nullptr) , _pCollider(nullptr)
, m_pParent(nullptr) , _pParent(nullptr)
, m_pParentScene(nullptr) , _pParentScene(nullptr)
, m_nHashName(0) , _nHashName(0)
, m_bSortChildrenNeeded(false) , _bSortChildrenNeeded(false)
, m_bTransformNeeded(false) , _bTransformNeeded(false)
, m_bAutoUpdate(true) , _bAutoUpdate(true)
, m_bPositionFixed(false) , _bPositionFixed(false)
{ {
if (s_fDefaultColliderEnabled) if (s_fDefaultColliderEnabled)
{ {
@ -49,14 +49,14 @@ e2d::Node::~Node()
void e2d::Node::_update() void e2d::Node::_update()
{ {
if (m_bTransformNeeded) if (_bTransformNeeded)
{ {
_updateTransform(); _updateTransform();
} }
if (!m_vChildren.empty()) if (!_vChildren.empty())
{ {
if (m_bSortChildrenNeeded) if (_bSortChildrenNeeded)
{ {
// 子节点排序 // 子节点排序
auto sortFunc = [](Node * n1, Node * n2) { auto sortFunc = [](Node * n1, Node * n2) {
@ -64,20 +64,20 @@ void e2d::Node::_update()
}; };
std::sort( std::sort(
std::begin(m_vChildren), std::begin(_vChildren),
std::end(m_vChildren), std::end(_vChildren),
sortFunc sortFunc
); );
m_bSortChildrenNeeded = false; _bSortChildrenNeeded = false;
} }
// 遍历子节点 // 遍历子节点
size_t size = m_vChildren.size(); size_t size = _vChildren.size();
size_t i; size_t i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
auto child = m_vChildren[i]; auto child = _vChildren[i];
// 访问 Order 小于零的节点 // 访问 Order 小于零的节点
if (child->getOrder() < 0) if (child->getOrder() < 0)
{ {
@ -89,7 +89,7 @@ void e2d::Node::_update()
} }
} }
if (m_bAutoUpdate) if (_bAutoUpdate)
{ {
if (!Game::isPaused()) if (!Game::isPaused())
{ {
@ -100,11 +100,11 @@ void e2d::Node::_update()
// 访问剩余节点 // 访问剩余节点
for (; i < size; i++) for (; i < size; i++)
m_vChildren[i]->_update(); _vChildren[i]->_update();
} }
else else
{ {
if (m_bAutoUpdate) if (_bAutoUpdate)
{ {
if (!Game::isPaused()) if (!Game::isPaused())
{ {
@ -117,18 +117,18 @@ void e2d::Node::_update()
void e2d::Node::_render() void e2d::Node::_render()
{ {
if (!m_bVisiable) if (!_bVisiable)
{ {
return; return;
} }
if (!m_vChildren.empty()) if (!_vChildren.empty())
{ {
size_t size = m_vChildren.size(); size_t size = _vChildren.size();
size_t i; size_t i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
auto child = m_vChildren[i]; auto child = _vChildren[i];
// 访问 Order 小于零的节点 // 访问 Order 小于零的节点
if (child->getOrder() < 0) if (child->getOrder() < 0)
{ {
@ -141,18 +141,18 @@ void e2d::Node::_render()
} }
// 转换渲染器的二维矩阵 // 转换渲染器的二维矩阵
Renderer::getRenderTarget()->SetTransform(m_MatriFinal); Renderer::getRenderTarget()->SetTransform(_MatriFinal);
// 渲染自身 // 渲染自身
this->onRender(); this->onRender();
// 访问剩余节点 // 访问剩余节点
for (; i < size; i++) for (; i < size; i++)
m_vChildren[i]->_render(); _vChildren[i]->_render();
} }
else else
{ {
// 转换渲染器的二维矩阵 // 转换渲染器的二维矩阵
Renderer::getRenderTarget()->SetTransform(m_MatriFinal); Renderer::getRenderTarget()->SetTransform(_MatriFinal);
// 渲染自身 // 渲染自身
this->onRender(); this->onRender();
} }
@ -161,13 +161,13 @@ void e2d::Node::_render()
void e2d::Node::_drawCollider() 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(); child->_drawCollider();
} }
@ -176,30 +176,30 @@ void e2d::Node::_drawCollider()
void e2d::Node::_updateSelfTransform() 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 矩阵,子节点将根据这个矩阵进行变换 // 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
m_MatriInitial = D2D1::Matrix3x2F::Scale( _MatriInitial = D2D1::Matrix3x2F::Scale(
m_fScaleX, _fScaleX,
m_fScaleY, _fScaleY,
pivot pivot
) * D2D1::Matrix3x2F::Skew( ) * D2D1::Matrix3x2F::Skew(
m_fSkewAngleX, _fSkewAngleX,
m_fSkewAngleY, _fSkewAngleY,
pivot pivot
) * D2D1::Matrix3x2F::Rotation( ) * D2D1::Matrix3x2F::Rotation(
m_fRotation, _fRotation,
pivot pivot
) * D2D1::Matrix3x2F::Translation( ) * D2D1::Matrix3x2F::Translation(
m_fPosX, _fPosX,
m_fPosY _fPosY
); );
// 根据自身中心点变换 Final 矩阵 // 根据自身中心点变换 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; _MatriInitial = _MatriInitial * _pParent->_MatriInitial;
m_MatriFinal = m_MatriFinal * m_pParent->m_MatriInitial; _MatriFinal = _MatriFinal * _pParent->_MatriInitial;
} }
} }
@ -208,14 +208,14 @@ void e2d::Node::_updateTransform()
// 计算自身的转换矩阵 // 计算自身的转换矩阵
_updateSelfTransform(); _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(); child->_updateTransform();
} }
@ -223,11 +223,11 @@ void e2d::Node::_updateTransform()
void e2d::Node::_updateOpacity() 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(); child->_updateOpacity();
} }
@ -235,67 +235,67 @@ void e2d::Node::_updateOpacity()
bool e2d::Node::isVisiable() const bool e2d::Node::isVisiable() const
{ {
return m_bVisiable; return _bVisiable;
} }
e2d::String e2d::Node::getName() const e2d::String e2d::Node::getName() const
{ {
return m_sName; return _sName;
} }
unsigned int e2d::Node::getHashName() const unsigned int e2d::Node::getHashName() const
{ {
return m_nHashName; return _nHashName;
} }
double e2d::Node::getPosX() const double e2d::Node::getPosX() const
{ {
return m_fPosX; return _fPosX;
} }
double e2d::Node::getPosY() const double e2d::Node::getPosY() const
{ {
return m_fPosY; return _fPosY;
} }
e2d::Point e2d::Node::getPos() const e2d::Point e2d::Node::getPos() const
{ {
return Point(m_fPosX, m_fPosY); return Point(_fPosX, _fPosY);
} }
double e2d::Node::getWidth() const double e2d::Node::getWidth() const
{ {
return m_fWidth * m_fScaleX; return _fWidth * _fScaleX;
} }
double e2d::Node::getHeight() const double e2d::Node::getHeight() const
{ {
return m_fHeight * m_fScaleY; return _fHeight * _fScaleY;
} }
double e2d::Node::getRealWidth() const double e2d::Node::getRealWidth() const
{ {
return m_fWidth; return _fWidth;
} }
double e2d::Node::getRealHeight() const double e2d::Node::getRealHeight() const
{ {
return m_fHeight; return _fHeight;
} }
e2d::Size e2d::Node::getRealSize() const e2d::Size e2d::Node::getRealSize() const
{ {
return Size(m_fWidth, m_fHeight); return Size(_fWidth, _fHeight);
} }
double e2d::Node::getPivotX() const double e2d::Node::getPivotX() const
{ {
return m_fPivotX; return _fPivotX;
} }
double e2d::Node::getPivotY() const double e2d::Node::getPivotY() const
{ {
return m_fPivotY; return _fPivotY;
} }
e2d::Size e2d::Node::getSize() const e2d::Size e2d::Node::getSize() const
@ -305,76 +305,76 @@ e2d::Size e2d::Node::getSize() const
double e2d::Node::getScaleX() const double e2d::Node::getScaleX() const
{ {
return m_fScaleX; return _fScaleX;
} }
double e2d::Node::getScaleY() const double e2d::Node::getScaleY() const
{ {
return m_fScaleY; return _fScaleY;
} }
double e2d::Node::getSkewX() const double e2d::Node::getSkewX() const
{ {
return m_fSkewAngleX; return _fSkewAngleX;
} }
double e2d::Node::getSkewY() const double e2d::Node::getSkewY() const
{ {
return m_fSkewAngleY; return _fSkewAngleY;
} }
double e2d::Node::getRotation() const double e2d::Node::getRotation() const
{ {
return m_fRotation; return _fRotation;
} }
double e2d::Node::getOpacity() const double e2d::Node::getOpacity() const
{ {
return m_fRealOpacity; return _fRealOpacity;
} }
e2d::NodeProperty e2d::Node::getProperty() const e2d::NodeProperty e2d::Node::getProperty() const
{ {
NodeProperty prop; NodeProperty prop;
prop.visable = m_bVisiable; prop.visable = _bVisiable;
prop.posX = m_fPosX; prop.posX = _fPosX;
prop.posY = m_fPosY; prop.posY = _fPosY;
prop.width = m_fWidth; prop.width = _fWidth;
prop.height = m_fHeight; prop.height = _fHeight;
prop.opacity = m_fRealOpacity; prop.opacity = _fRealOpacity;
prop.pivotX = m_fPivotX; prop.pivotX = _fPivotX;
prop.pivotY = m_fPivotY; prop.pivotY = _fPivotY;
prop.scaleX = m_fScaleX; prop.scaleX = _fScaleX;
prop.scaleY = m_fScaleY; prop.scaleY = _fScaleY;
prop.rotation = m_fRotation; prop.rotation = _fRotation;
prop.skewAngleX = m_fSkewAngleX; prop.skewAngleX = _fSkewAngleX;
prop.skewAngleY = m_fSkewAngleY; prop.skewAngleY = _fSkewAngleY;
return prop; return prop;
} }
e2d::Collider * e2d::Node::getCollider() const e2d::Collider * e2d::Node::getCollider() const
{ {
return m_pCollider; return _pCollider;
} }
int e2d::Node::getOrder() const int e2d::Node::getOrder() const
{ {
return m_nOrder; return _nOrder;
} }
void e2d::Node::setOrder(int order) void e2d::Node::setOrder(int order)
{ {
m_nOrder = order; _nOrder = order;
} }
void e2d::Node::setPosX(double x) void e2d::Node::setPosX(double x)
{ {
this->setPos(x, m_fPosY); this->setPos(x, _fPosY);
} }
void e2d::Node::setPosY(double y) void e2d::Node::setPosY(double y)
{ {
this->setPos(m_fPosX, y); this->setPos(_fPosX, y);
} }
void e2d::Node::setPos(const Point & p) 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) void e2d::Node::setPos(double x, double y)
{ {
if (m_fPosX == x && m_fPosY == y) if (_fPosX == x && _fPosY == y)
return; return;
m_fPosX = static_cast<float>(x); _fPosX = static_cast<float>(x);
m_fPosY = static_cast<float>(y); _fPosY = static_cast<float>(y);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setPosFixed(bool fixed) void e2d::Node::setPosFixed(bool fixed)
{ {
if (m_bPositionFixed == fixed) if (_bPositionFixed == fixed)
return; return;
m_bPositionFixed = fixed; _bPositionFixed = fixed;
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::movePosX(double x) void e2d::Node::movePosX(double x)
@ -413,7 +413,7 @@ void e2d::Node::movePosY(double y)
void e2d::Node::movePos(double x, 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) void e2d::Node::movePos(const Vector & v)
@ -423,12 +423,12 @@ void e2d::Node::movePos(const Vector & v)
void e2d::Node::setScaleX(double scaleX) void e2d::Node::setScaleX(double scaleX)
{ {
this->setScale(scaleX, m_fScaleY); this->setScale(scaleX, _fScaleY);
} }
void e2d::Node::setScaleY(double scaleY) void e2d::Node::setScaleY(double scaleY)
{ {
this->setScale(m_fScaleX, scaleY); this->setScale(_fScaleX, scaleY);
} }
void e2d::Node::setScale(double scale) void e2d::Node::setScale(double scale)
@ -438,91 +438,91 @@ void e2d::Node::setScale(double scale)
void e2d::Node::setScale(double scaleX, double scaleY) void e2d::Node::setScale(double scaleX, double scaleY)
{ {
if (m_fScaleX == scaleX && m_fScaleY == scaleY) if (_fScaleX == scaleX && _fScaleY == scaleY)
return; return;
m_fScaleX = static_cast<float>(scaleX); _fScaleX = static_cast<float>(scaleX);
m_fScaleY = static_cast<float>(scaleY); _fScaleY = static_cast<float>(scaleY);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setSkewX(double angleX) void e2d::Node::setSkewX(double angleX)
{ {
this->setSkew(angleX, m_fSkewAngleY); this->setSkew(angleX, _fSkewAngleY);
} }
void e2d::Node::setSkewY(double angleY) void e2d::Node::setSkewY(double angleY)
{ {
this->setSkew(m_fSkewAngleX, angleY); this->setSkew(_fSkewAngleX, angleY);
} }
void e2d::Node::setSkew(double angleX, double angleY) void e2d::Node::setSkew(double angleX, double angleY)
{ {
if (m_fSkewAngleX == angleX && m_fSkewAngleY == angleY) if (_fSkewAngleX == angleX && _fSkewAngleY == angleY)
return; return;
m_fSkewAngleX = static_cast<float>(angleX); _fSkewAngleX = static_cast<float>(angleX);
m_fSkewAngleY = static_cast<float>(angleY); _fSkewAngleY = static_cast<float>(angleY);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setRotation(double angle) void e2d::Node::setRotation(double angle)
{ {
if (m_fRotation == angle) if (_fRotation == angle)
return; return;
m_fRotation = static_cast<float>(angle); _fRotation = static_cast<float>(angle);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setOpacity(double opacity) void e2d::Node::setOpacity(double opacity)
{ {
if (m_fRealOpacity == opacity) if (_fRealOpacity == opacity)
return; return;
m_fDisplayOpacity = m_fRealOpacity = min(max(static_cast<float>(opacity), 0), 1); _fDisplayOpacity = _fRealOpacity = min(max(static_cast<float>(opacity), 0), 1);
// 更新节点透明度 // 更新节点透明度
_updateOpacity(); _updateOpacity();
} }
void e2d::Node::setPivotX(double pivotX) void e2d::Node::setPivotX(double pivotX)
{ {
this->setPivot(pivotX, m_fPivotY); this->setPivot(pivotX, _fPivotY);
} }
void e2d::Node::setPivotY(double pivotY) void e2d::Node::setPivotY(double pivotY)
{ {
this->setPivot(m_fPivotX, pivotY); this->setPivot(_fPivotX, pivotY);
} }
void e2d::Node::setPivot(double pivotX, double pivotY) void e2d::Node::setPivot(double pivotX, double pivotY)
{ {
if (m_fPivotX == pivotX && m_fPivotY == pivotY) if (_fPivotX == pivotX && _fPivotY == pivotY)
return; return;
m_fPivotX = min(max(static_cast<float>(pivotX), 0), 1); _fPivotX = min(max(static_cast<float>(pivotX), 0), 1);
m_fPivotY = min(max(static_cast<float>(pivotY), 0), 1); _fPivotY = min(max(static_cast<float>(pivotY), 0), 1);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setWidth(double width) void e2d::Node::setWidth(double width)
{ {
this->setSize(width, m_fHeight); this->setSize(width, _fHeight);
} }
void e2d::Node::setHeight(double height) void e2d::Node::setHeight(double height)
{ {
this->setSize(m_fWidth, height); this->setSize(_fWidth, height);
} }
void e2d::Node::setSize(double width, double height) void e2d::Node::setSize(double width, double height)
{ {
if (m_fWidth == width && m_fHeight == height) if (_fWidth == width && _fHeight == height)
return; return;
m_fWidth = static_cast<float>(width); _fWidth = static_cast<float>(width);
m_fHeight = static_cast<float>(height); _fHeight = static_cast<float>(height);
m_bTransformNeeded = true; _bTransformNeeded = true;
} }
void e2d::Node::setSize(Size size) void e2d::Node::setSize(Size size)
@ -575,26 +575,26 @@ void e2d::Node::setCollider(ColliderType nColliderType)
void e2d::Node::setCollider(Collider * pCollider) void e2d::Node::setCollider(Collider * pCollider)
{ {
// 删除旧的碰撞体 // 删除旧的碰撞体
ColliderManager::__removeCollider(m_pCollider); ColliderManager::__removeCollider(_pCollider);
// 添加新的碰撞体 // 添加新的碰撞体
ColliderManager::__addCollider(pCollider); ColliderManager::__addCollider(pCollider);
if (pCollider) if (pCollider)
{ {
// 双向绑定 // 双向绑定
this->m_pCollider = pCollider; this->_pCollider = pCollider;
pCollider->m_pParentNode = this; pCollider->_pParentNode = this;
} }
else else
{ {
this->m_pCollider = nullptr; this->_pCollider = nullptr;
} }
} }
void e2d::Node::addColliableName(const String& collliderName) void e2d::Node::addColliableName(const String& collliderName)
{ {
unsigned int hash = collliderName.getHashCode(); unsigned int hash = collliderName.getHashCode();
m_vColliders.insert(hash); _vColliders.insert(hash);
} }
#ifdef HIGHER_THAN_VS2012 #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) void e2d::Node::removeColliableName(const String& collliderName)
{ {
unsigned int hash = collliderName.getHashCode(); unsigned int hash = collliderName.getHashCode();
m_vColliders.erase(hash); _vColliders.erase(hash);
} }
void e2d::Node::addChild(Node * child, int order /* = 0 */) void e2d::Node::addChild(Node * child, int order /* = 0 */)
@ -619,32 +619,32 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
if (child) 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()) for (Node * parent = this; parent != nullptr; parent = parent->getParent())
{ {
ASSERT(child != parent, "A Node cannot be the child of his own children!"); 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->setOrder(order);
child->retain(); 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->_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 e2d::Node * e2d::Node::getParent() const
{ {
return m_pParent; return _pParent;
} }
e2d::Scene * e2d::Node::getParentScene() const e2d::Scene * e2d::Node::getParentScene() const
{ {
return m_pParentScene; return _pParentScene;
} }
std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const 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; std::vector<Node*> vChildren;
unsigned int hash = name.getHashCode(); unsigned int hash = name.getHashCode();
for (auto child : m_vChildren) for (auto child : _vChildren)
{ {
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度 // 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
if (child->m_nHashName == hash && child->m_sName == name) if (child->_nHashName == hash && child->_sName == name)
{ {
vChildren.push_back(child); vChildren.push_back(child);
} }
@ -688,10 +688,10 @@ e2d::Node * e2d::Node::getChild(const String& name) const
{ {
unsigned int hash = name.getHashCode(); unsigned int hash = name.getHashCode();
for (auto child : m_vChildren) for (auto child : _vChildren)
{ {
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度 // 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
if (child->m_nHashName == hash && child->m_sName == name) if (child->_nHashName == hash && child->_sName == name)
{ {
return child; return child;
} }
@ -701,19 +701,19 @@ e2d::Node * e2d::Node::getChild(const String& name) const
std::vector<e2d::Node*> e2d::Node::getAllChildren() const std::vector<e2d::Node*> e2d::Node::getAllChildren() const
{ {
return m_vChildren; return _vChildren;
} }
int e2d::Node::getChildrenCount() const int e2d::Node::getChildrenCount() const
{ {
return static_cast<int>(m_vChildren.size()); return static_cast<int>(_vChildren.size());
} }
void e2d::Node::removeFromParent() 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."); WARN_IF(child == nullptr, "Node::removeChildren NULL pointer exception.");
if (m_vChildren.empty()) if (_vChildren.empty())
{ {
return false; return false;
} }
if (child) if (child)
{ {
size_t size = m_vChildren.size(); size_t size = _vChildren.size();
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
if (m_vChildren[i] == child) if (_vChildren[i] == child)
{ {
m_vChildren.erase(m_vChildren.begin() + i); _vChildren.erase(_vChildren.begin() + i);
child->m_pParent = nullptr; child->_pParent = nullptr;
if (child->m_pParentScene) if (child->_pParentScene)
{ {
child->_setParentScene(nullptr); child->_setParentScene(nullptr);
} }
@ -753,7 +753,7 @@ void e2d::Node::removeChildren(const String& childName)
{ {
WARN_IF(childName.isEmpty(), "Invalid Node name."); WARN_IF(childName.isEmpty(), "Invalid Node name.");
if (m_vChildren.empty()) if (_vChildren.empty())
{ {
return; return;
} }
@ -761,15 +761,15 @@ void e2d::Node::removeChildren(const String& childName)
// 计算名称 Hash 值 // 计算名称 Hash 值
unsigned int hash = childName.getHashCode(); unsigned int hash = childName.getHashCode();
size_t size = m_vChildren.size(); size_t size = _vChildren.size();
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
auto child = m_vChildren[i]; auto child = _vChildren[i];
if (child->m_nHashName == hash && child->m_sName == childName) if (child->_nHashName == hash && child->_sName == childName)
{ {
m_vChildren.erase(m_vChildren.begin() + i); _vChildren.erase(_vChildren.begin() + i);
child->m_pParent = nullptr; child->_pParent = nullptr;
if (child->m_pParentScene) if (child->_pParentScene)
{ {
child->_setParentScene(nullptr); child->_setParentScene(nullptr);
} }
@ -781,28 +781,20 @@ void e2d::Node::removeChildren(const String& childName)
void e2d::Node::clearAllChildren() void e2d::Node::clearAllChildren()
{ {
// 所有节点的引用计数减一 // 所有节点的引用计数减一
for (auto child : m_vChildren) for (auto child : _vChildren)
{ {
child->release(); child->release();
} }
// 清空储存节点的容器 // 清空储存节点的容器
m_vChildren.clear(); _vChildren.clear();
} }
void e2d::Node::runAction(ActionBase * action) void e2d::Node::runAction(ActionBase * action)
{ {
if (this != action->getTarget()) if (this != action->getTarget())
{ {
WARN_IF( ASSERT(action->getTarget() == nullptr, "The action has already got a target!");
nullptr != action->getTarget(), ActionManager::start(action, this, false);
"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);
} }
else else
{ {
@ -881,13 +873,13 @@ bool e2d::Node::isPointIn(Point point) const
{ {
BOOL ret = 0; BOOL ret = 0;
// 如果存在碰撞体,用碰撞体判断 // 如果存在碰撞体,用碰撞体判断
if (m_pCollider) if (_pCollider)
{ {
m_pCollider->getD2dGeometry()->FillContainsPoint( _pCollider->getD2dGeometry()->FillContainsPoint(
D2D1::Point2F( D2D1::Point2F(
static_cast<float>(point.x), static_cast<float>(point.x),
static_cast<float>(point.y)), static_cast<float>(point.y)),
m_MatriFinal, _MatriFinal,
&ret &ret
); );
} }
@ -896,7 +888,7 @@ bool e2d::Node::isPointIn(Point point) const
// 为节点创建一个临时碰撞体 // 为节点创建一个临时碰撞体
ID2D1RectangleGeometry * rect; ID2D1RectangleGeometry * rect;
Renderer::getID2D1Factory()->CreateRectangleGeometry( Renderer::getID2D1Factory()->CreateRectangleGeometry(
D2D1::RectF(0, 0, m_fWidth, m_fHeight), D2D1::RectF(0, 0, _fWidth, _fHeight),
&rect &rect
); );
// 判断点是否在碰撞体内 // 判断点是否在碰撞体内
@ -904,7 +896,7 @@ bool e2d::Node::isPointIn(Point point) const
D2D1::Point2F( D2D1::Point2F(
static_cast<float>(point.x), static_cast<float>(point.x),
static_cast<float>(point.y)), static_cast<float>(point.y)),
m_MatriFinal, _MatriFinal,
&ret &ret
); );
// 删除临时创建的碰撞体 // 删除临时创建的碰撞体
@ -919,12 +911,12 @@ bool e2d::Node::isPointIn(Point point) const
return false; 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) && if ((relation != Relation::UNKNOWN) &&
(relation != Relation::DISJOINT)) (relation != Relation::DISJOINT))
{ {
@ -941,24 +933,24 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
// 根据自身大小位置创建矩形 // 根据自身大小位置创建矩形
Renderer::getID2D1Factory()->CreateRectangleGeometry( Renderer::getID2D1Factory()->CreateRectangleGeometry(
D2D1::RectF(0, 0, m_fWidth, m_fHeight), D2D1::RectF(0, 0, _fWidth, _fHeight),
&pRect1 &pRect1
); );
// 根据二维矩阵进行转换 // 根据二维矩阵进行转换
Renderer::getID2D1Factory()->CreateTransformedGeometry( Renderer::getID2D1Factory()->CreateTransformedGeometry(
pRect1, pRect1,
m_MatriFinal, _MatriFinal,
&pCollider &pCollider
); );
// 根据相比较节点的大小位置创建矩形 // 根据相比较节点的大小位置创建矩形
Renderer::getID2D1Factory()->CreateRectangleGeometry( Renderer::getID2D1Factory()->CreateRectangleGeometry(
D2D1::RectF(0, 0, pNode->m_fWidth, pNode->m_fHeight), D2D1::RectF(0, 0, node->_fWidth, node->_fHeight),
&pRect2 &pRect2
); );
// 获取相交状态 // 获取相交状态
pCollider->CompareWithGeometry( pCollider->CompareWithGeometry(
pRect2, pRect2,
pNode->m_MatriFinal, node->_MatriFinal,
&relation &relation
); );
// 删除临时创建的碰撞体 // 删除临时创建的碰撞体
@ -977,7 +969,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
void e2d::Node::setAutoUpdate(bool bAutoUpdate) void e2d::Node::setAutoUpdate(bool bAutoUpdate)
{ {
m_bAutoUpdate = bAutoUpdate; _bAutoUpdate = bAutoUpdate;
} }
void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY) void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY)
@ -994,8 +986,8 @@ void e2d::Node::setDefaultColliderEnable(bool enable)
void e2d::Node::destroy() void e2d::Node::destroy()
{ {
ActionManager::__clearAllBindedWith(this); ActionManager::__clearAllBindedWith(this);
ColliderManager::__removeCollider(m_pCollider); ColliderManager::__removeCollider(_pCollider);
for (auto child : m_vChildren) for (auto child : _vChildren)
{ {
SafeRelease(&child); SafeRelease(&child);
} }
@ -1018,26 +1010,26 @@ void e2d::Node::stopAllActions()
void e2d::Node::setVisiable(bool value) void e2d::Node::setVisiable(bool value)
{ {
m_bVisiable = value; _bVisiable = value;
} }
void e2d::Node::setName(const String& name) void e2d::Node::setName(const String& name)
{ {
WARN_IF(name.isEmpty(), "Invalid Node 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 名 // 保存节点 Hash 名
m_nHashName = name.getHashCode(); _nHashName = name.getHashCode();
} }
} }
void e2d::Node::_setParentScene(Scene * scene) void e2d::Node::_setParentScene(Scene * scene)
{ {
m_pParentScene = scene; _pParentScene = scene;
for (auto child : m_vChildren) for (auto child : _vChildren)
{ {
child->_setParentScene(scene); child->_setParentScene(scene);
} }

View File

@ -1,7 +1,7 @@
#include "..\..\e2dshape.h" #include "..\..\e2dshape.h"
e2d::Circle::Circle() e2d::Circle::Circle()
: m_fRadius(0) : _fRadius(0)
{ {
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
@ -32,28 +32,28 @@ e2d::Circle::~Circle()
double e2d::Circle::getRadius() const double e2d::Circle::getRadius() const
{ {
return m_fRadius; return _fRadius;
} }
void e2d::Circle::setRadius(double radius) void e2d::Circle::setRadius(double radius)
{ {
m_fRadius = static_cast<float>(radius); _fRadius = static_cast<float>(radius);
Node::setSize(radius * 2, radius * 2); Node::setSize(radius * 2, radius * 2);
} }
void e2d::Circle::_renderLine() void e2d::Circle::_renderLine()
{ {
Renderer::getRenderTarget()->DrawEllipse( 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(), Renderer::getSolidColorBrush(),
m_fStrokeWidth _fStrokeWidth
); );
} }
void e2d::Circle::_renderFill() void e2d::Circle::_renderFill()
{ {
Renderer::getRenderTarget()->FillEllipse( 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() Renderer::getSolidColorBrush()
); );
} }

View File

@ -1,8 +1,8 @@
#include "..\..\e2dshape.h" #include "..\..\e2dshape.h"
e2d::Ellipse::Ellipse() e2d::Ellipse::Ellipse()
: m_fRadiusX(0) : _fRadiusX(0)
, m_fRadiusY(0) , _fRadiusY(0)
{ {
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
@ -36,39 +36,39 @@ e2d::Ellipse::~Ellipse()
double e2d::Ellipse::getRadiusX() const double e2d::Ellipse::getRadiusX() const
{ {
return m_fRadiusX; return _fRadiusX;
} }
double e2d::Ellipse::getRadiusY() const double e2d::Ellipse::getRadiusY() const
{ {
return m_fRadiusY; return _fRadiusY;
} }
void e2d::Ellipse::setRadiusX(double radiusX) void e2d::Ellipse::setRadiusX(double radiusX)
{ {
m_fRadiusX = static_cast<float>(radiusX); _fRadiusX = static_cast<float>(radiusX);
Node::setWidth(radiusX * 2); Node::setWidth(radiusX * 2);
} }
void e2d::Ellipse::setRadiusY(double radiusY) void e2d::Ellipse::setRadiusY(double radiusY)
{ {
m_fRadiusY = static_cast<float>(radiusY); _fRadiusY = static_cast<float>(radiusY);
Node::setHeight(radiusY * 2); Node::setHeight(radiusY * 2);
} }
void e2d::Ellipse::_renderLine() void e2d::Ellipse::_renderLine()
{ {
Renderer::getRenderTarget()->DrawEllipse( 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(), Renderer::getSolidColorBrush(),
m_fStrokeWidth _fStrokeWidth
); );
} }
void e2d::Ellipse::_renderFill() void e2d::Ellipse::_renderFill()
{ {
Renderer::getRenderTarget()->FillEllipse( 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() Renderer::getSolidColorBrush()
); );
} }

View File

@ -35,16 +35,16 @@ e2d::Rect::~Rect()
void e2d::Rect::_renderLine() void e2d::Rect::_renderLine()
{ {
Renderer::getRenderTarget()->DrawRectangle( Renderer::getRenderTarget()->DrawRectangle(
D2D1::RectF(0, 0, m_fWidth, m_fHeight), D2D1::RectF(0, 0, _fWidth, _fHeight),
Renderer::getSolidColorBrush(), Renderer::getSolidColorBrush(),
m_fStrokeWidth _fStrokeWidth
); );
} }
void e2d::Rect::_renderFill() void e2d::Rect::_renderFill()
{ {
Renderer::getRenderTarget()->FillRectangle( Renderer::getRenderTarget()->FillRectangle(
D2D1::RectF(0, 0, m_fWidth, m_fHeight), D2D1::RectF(0, 0, _fWidth, _fHeight),
Renderer::getSolidColorBrush() Renderer::getSolidColorBrush()
); );
} }

View File

@ -1,28 +1,28 @@
#include "..\..\e2dshape.h" #include "..\..\e2dshape.h"
e2d::RoundRect::RoundRect() e2d::RoundRect::RoundRect()
: m_fRadiusX(0) : _fRadiusX(0)
, m_fRadiusY(0) , _fRadiusY(0)
{ {
} }
e2d::RoundRect::RoundRect(double width, double height, double radiusX, double radiusY) e2d::RoundRect::RoundRect(double width, double height, double radiusX, double radiusY)
: m_fRadiusX(static_cast<float>(radiusX)) : _fRadiusX(static_cast<float>(radiusX))
, m_fRadiusY(static_cast<float>(radiusY)) , _fRadiusY(static_cast<float>(radiusY))
{ {
this->setSize(width, height); this->setSize(width, height);
} }
e2d::RoundRect::RoundRect(Size size, double radiusX, double radiusY) e2d::RoundRect::RoundRect(Size size, double radiusX, double radiusY)
: m_fRadiusX(static_cast<float>(radiusX)) : _fRadiusX(static_cast<float>(radiusX))
, m_fRadiusY(static_cast<float>(radiusY)) , _fRadiusY(static_cast<float>(radiusY))
{ {
this->setSize(size); this->setSize(size);
} }
e2d::RoundRect::RoundRect(double top, double left, double width, double height, double radiusX, double radiusY) e2d::RoundRect::RoundRect(double top, double left, double width, double height, double radiusX, double radiusY)
: m_fRadiusX(static_cast<float>(radiusX)) : _fRadiusX(static_cast<float>(radiusX))
, m_fRadiusY(static_cast<float>(radiusY)) , _fRadiusY(static_cast<float>(radiusY))
{ {
this->setPivot(0, 0); this->setPivot(0, 0);
this->setPos(top, left); 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) e2d::RoundRect::RoundRect(Point topLeft, Size size, double radiusX, double radiusY)
: m_fRadiusX(static_cast<float>(radiusX)) : _fRadiusX(static_cast<float>(radiusX))
, m_fRadiusY(static_cast<float>(radiusY)) , _fRadiusY(static_cast<float>(radiusY))
{ {
this->setPivot(0, 0); this->setPivot(0, 0);
this->setPos(topLeft); this->setPos(topLeft);
@ -44,37 +44,37 @@ e2d::RoundRect::~RoundRect()
double e2d::RoundRect::getRadiusX() const double e2d::RoundRect::getRadiusX() const
{ {
return m_fRadiusX; return _fRadiusX;
} }
double e2d::RoundRect::getRadiusY() const double e2d::RoundRect::getRadiusY() const
{ {
return m_fRadiusY; return _fRadiusY;
} }
void e2d::RoundRect::setRadiusX(double radiusX) void e2d::RoundRect::setRadiusX(double radiusX)
{ {
m_fRadiusX = static_cast<float>(radiusX); _fRadiusX = static_cast<float>(radiusX);
} }
void e2d::RoundRect::setRadiusY(double radiusY) void e2d::RoundRect::setRadiusY(double radiusY)
{ {
m_fRadiusY = static_cast<float>(radiusY); _fRadiusY = static_cast<float>(radiusY);
} }
void e2d::RoundRect::_renderLine() void e2d::RoundRect::_renderLine()
{ {
Renderer::getRenderTarget()->DrawRoundedRectangle( 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(), Renderer::getSolidColorBrush(),
m_fStrokeWidth _fStrokeWidth
); );
} }
void e2d::RoundRect::_renderFill() void e2d::RoundRect::_renderFill()
{ {
Renderer::getRenderTarget()->FillRoundedRectangle( 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() Renderer::getSolidColorBrush()
); );
} }

View File

@ -1,10 +1,10 @@
#include "..\..\e2dshape.h" #include "..\..\e2dshape.h"
e2d::Shape::Shape() e2d::Shape::Shape()
: m_nStyle(ShapeStyle::SOLID) : _nStyle(ShapeStyle::SOLID)
, m_nFillColor(Color::WHITE) , _nFillColor(Color::WHITE)
, m_nLineColor(Color::BLUE, 0.5) , _nLineColor(Color::BLUE, 0.5)
, m_fStrokeWidth(1) , _fStrokeWidth(1)
{ {
} }
@ -15,30 +15,30 @@ e2d::Shape::~Shape()
void e2d::Shape::onRender() void e2d::Shape::onRender()
{ {
auto pBrush = Renderer::getSolidColorBrush(); auto pBrush = Renderer::getSolidColorBrush();
pBrush->SetOpacity(m_fDisplayOpacity); pBrush->SetOpacity(_fDisplayOpacity);
switch (m_nStyle) switch (_nStyle)
{ {
case ShapeStyle::FILL: case ShapeStyle::FILL:
{ {
pBrush->SetColor(m_nFillColor.toColorF()); pBrush->SetColor(_nFillColor.toColorF());
this->_renderFill(); this->_renderFill();
pBrush->SetColor(m_nLineColor.toColorF()); pBrush->SetColor(_nLineColor.toColorF());
this->_renderLine(); this->_renderLine();
break; break;
} }
case ShapeStyle::ROUND: case ShapeStyle::ROUND:
{ {
pBrush->SetColor(m_nLineColor.toColorF()); pBrush->SetColor(_nLineColor.toColorF());
this->_renderLine(); this->_renderLine();
break; break;
} }
case ShapeStyle::SOLID: case ShapeStyle::SOLID:
{ {
pBrush->SetColor(m_nFillColor.toColorF()); pBrush->SetColor(_nFillColor.toColorF());
this->_renderFill(); this->_renderFill();
break; break;
} }
@ -50,40 +50,40 @@ void e2d::Shape::onRender()
e2d::Color e2d::Shape::getFillColor() const e2d::Color e2d::Shape::getFillColor() const
{ {
return m_nFillColor; return _nFillColor;
} }
e2d::Color e2d::Shape::getLineColor() const e2d::Color e2d::Shape::getLineColor() const
{ {
return m_nLineColor; return _nLineColor;
} }
double e2d::Shape::getStrokeWidth() const double e2d::Shape::getStrokeWidth() const
{ {
return m_fStrokeWidth; return _fStrokeWidth;
} }
e2d::ShapeStyle e2d::Shape::getStyle() const e2d::ShapeStyle e2d::Shape::getStyle() const
{ {
return m_nStyle; return _nStyle;
} }
void e2d::Shape::setFillColor(Color fillColor) void e2d::Shape::setFillColor(Color fillColor)
{ {
m_nFillColor = fillColor; _nFillColor = fillColor;
} }
void e2d::Shape::setLineColor(Color lineColor) void e2d::Shape::setLineColor(Color lineColor)
{ {
m_nLineColor = lineColor; _nLineColor = lineColor;
} }
void e2d::Shape::setStrokeWidth(double strokeWidth) void e2d::Shape::setStrokeWidth(double strokeWidth)
{ {
m_fStrokeWidth = static_cast<float>(strokeWidth); _fStrokeWidth = static_cast<float>(strokeWidth);
} }
void e2d::Shape::setStyle(ShapeStyle style) void e2d::Shape::setStyle(ShapeStyle style)
{ {
m_nStyle = style; _nStyle = style;
} }

View File

@ -2,37 +2,37 @@
e2d::Sprite::Sprite() e2d::Sprite::Sprite()
: m_pImage(nullptr) : _pImage(nullptr)
{ {
} }
e2d::Sprite::Sprite(Image * image) e2d::Sprite::Sprite(Image * image)
: m_pImage(nullptr) : _pImage(nullptr)
{ {
open(image); open(image);
} }
e2d::Sprite::Sprite(const String& filePath) e2d::Sprite::Sprite(const String& filePath)
: m_pImage(nullptr) : _pImage(nullptr)
{ {
open(filePath); open(filePath);
} }
e2d::Sprite::Sprite(int resNameId, const String& resType) e2d::Sprite::Sprite(int resNameId, const String& resType)
: m_pImage(nullptr) : _pImage(nullptr)
{ {
open(resNameId, resType); open(resNameId, resType);
} }
e2d::Sprite::Sprite(const String& filePath, double x, double y, double width, double height) e2d::Sprite::Sprite(const String& filePath, double x, double y, double width, double height)
: m_pImage(nullptr) : _pImage(nullptr)
{ {
open(filePath); open(filePath);
crop(x, y, width, height); crop(x, y, width, height);
} }
e2d::Sprite::Sprite(int resNameId, const String& resType, double x, double y, double width, double 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); open(resNameId, resType);
crop(x, y, width, height); crop(x, y, width, height);
@ -46,11 +46,11 @@ bool e2d::Sprite::open(Image * image)
{ {
if (image) if (image)
{ {
SafeRelease(&m_pImage); SafeRelease(&_pImage);
m_pImage = image; _pImage = image;
m_pImage->retain(); _pImage->retain();
Node::setSize(m_pImage->getWidth(), m_pImage->getHeight()); Node::setSize(_pImage->getWidth(), _pImage->getHeight());
return true; return true;
} }
return false; return false;
@ -58,15 +58,15 @@ bool e2d::Sprite::open(Image * image)
bool e2d::Sprite::open(const String& filePath) bool e2d::Sprite::open(const String& filePath)
{ {
if (!m_pImage) if (!_pImage)
{ {
m_pImage = new (std::nothrow) Image(); _pImage = new (std::nothrow) Image();
m_pImage->retain(); _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 true;
} }
return false; return false;
@ -74,15 +74,15 @@ bool e2d::Sprite::open(const String& filePath)
bool e2d::Sprite::open(int resNameId, const String& resType) bool e2d::Sprite::open(int resNameId, const String& resType)
{ {
if (!m_pImage) if (!_pImage)
{ {
m_pImage = new (std::nothrow) Image(); _pImage = new (std::nothrow) Image();
m_pImage->retain(); _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 true;
} }
return false; 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) 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( Node::setSize(
min(max(width, 0), m_pImage->getSourceWidth() - m_pImage->getCropX()), min(max(width, 0), _pImage->getSourceWidth() - _pImage->getCropX()),
min(max(height, 0), m_pImage->getSourceHeight() - m_pImage->getCropY()) min(max(height, 0), _pImage->getSourceHeight() - _pImage->getCropY())
); );
} }
e2d::Image * e2d::Sprite::getImage() const e2d::Image * e2d::Sprite::getImage() const
{ {
return m_pImage; return _pImage;
} }
void e2d::Sprite::onRender() void e2d::Sprite::onRender()
{ {
if (m_pImage && m_pImage->getBitmap()) if (_pImage && _pImage->getBitmap())
{ {
// »ñȡͼƬ²Ã¼ôλÖà // »ñȡͼƬ²Ã¼ôλÖÃ
float fCropX = static_cast<float>(m_pImage->getCropX()); float fCropX = static_cast<float>(_pImage->getCropX());
float fCropY = static_cast<float>(m_pImage->getCropY()); float fCropY = static_cast<float>(_pImage->getCropY());
// äÖȾͼƬ // äÖȾͼƬ
Renderer::getRenderTarget()->DrawBitmap( Renderer::getRenderTarget()->DrawBitmap(
m_pImage->getBitmap(), _pImage->getBitmap(),
D2D1::RectF(0, 0, m_fWidth, m_fHeight), D2D1::RectF(0, 0, _fWidth, _fHeight),
m_fDisplayOpacity, _fDisplayOpacity,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
D2D1::RectF( D2D1::RectF(
fCropX, fCropX,
fCropY, fCropY,
fCropX + m_fWidth, fCropX + _fWidth,
fCropY + m_fHeight fCropY + _fHeight
) )
); );
} }
@ -128,5 +128,5 @@ void e2d::Sprite::onRender()
void e2d::Sprite::destroy() void e2d::Sprite::destroy()
{ {
Node::destroy(); Node::destroy();
SafeRelease(&m_pImage); SafeRelease(&_pImage);
} }

View File

@ -2,34 +2,34 @@
e2d::Text::Text() e2d::Text::Text()
: m_TextStyle() : _TextStyle()
, m_pDWriteTextLayout(nullptr) , _pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , _pDWriteTextFormat(nullptr)
{ {
} }
e2d::Text::Text(const String& text) e2d::Text::Text(const String& text)
: m_TextStyle() : _TextStyle()
, m_pDWriteTextLayout(nullptr) , _pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , _pDWriteTextFormat(nullptr)
, m_sText(text) , _sText(text)
{ {
_reset(); _reset();
} }
e2d::Text::Text(TextStyle textStyle) e2d::Text::Text(TextStyle textStyle)
: m_TextStyle(textStyle) : _TextStyle(textStyle)
, m_pDWriteTextLayout(nullptr) , _pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , _pDWriteTextFormat(nullptr)
{ {
_reset(); _reset();
} }
e2d::Text::Text(const String& text, TextStyle textStyle) e2d::Text::Text(const String& text, TextStyle textStyle)
: m_TextStyle(textStyle) : _TextStyle(textStyle)
, m_pDWriteTextLayout(nullptr) , _pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , _pDWriteTextFormat(nullptr)
, m_sText(text) , _sText(text)
{ {
_reset(); _reset();
} }
@ -51,7 +51,7 @@ e2d::Text::Text(
UINT32 outlineColor, UINT32 outlineColor,
UINT32 outlineWidth UINT32 outlineWidth
) )
: m_TextStyle( : _TextStyle(
fontFamily, fontFamily,
fontSize, fontSize,
color, color,
@ -67,70 +67,70 @@ e2d::Text::Text(
outlineColor, outlineColor,
outlineWidth outlineWidth
) )
, m_pDWriteTextLayout(nullptr) , _pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , _pDWriteTextFormat(nullptr)
, m_sText(text) , _sText(text)
{ {
_reset(); _reset();
} }
e2d::Text::~Text() e2d::Text::~Text()
{ {
SafeReleaseInterface(&m_pDWriteTextFormat); SafeReleaseInterface(&_pDWriteTextFormat);
SafeReleaseInterface(&m_pDWriteTextLayout); SafeReleaseInterface(&_pDWriteTextLayout);
} }
e2d::String e2d::Text::getText() const e2d::String e2d::Text::getText() const
{ {
return m_sText; return _sText;
} }
e2d::TextStyle e2d::Text::getTextStyle() const e2d::TextStyle e2d::Text::getTextStyle() const
{ {
return m_TextStyle; return _TextStyle;
} }
e2d::String e2d::Text::getFontFamily() const e2d::String e2d::Text::getFontFamily() const
{ {
return m_TextStyle.fontFamily; return _TextStyle.fontFamily;
} }
double e2d::Text::getFontSize() const double e2d::Text::getFontSize() const
{ {
return m_TextStyle.fontSize; return _TextStyle.fontSize;
} }
UINT32 e2d::Text::getFontWeight() const UINT32 e2d::Text::getFontWeight() const
{ {
return m_TextStyle.fontWeight; return _TextStyle.fontWeight;
} }
e2d::Color e2d::Text::getColor() const e2d::Color e2d::Text::getColor() const
{ {
return m_TextStyle.color; return _TextStyle.color;
} }
e2d::Color e2d::Text::getOutlineColor() const e2d::Color e2d::Text::getOutlineColor() const
{ {
return m_TextStyle.outlineColor; return _TextStyle.outlineColor;
} }
double e2d::Text::getOutlineWidth() const double e2d::Text::getOutlineWidth() const
{ {
return m_TextStyle.outlineWidth; return _TextStyle.outlineWidth;
} }
e2d::LineJoin e2d::Text::getOutlineJoin() const e2d::LineJoin e2d::Text::getOutlineJoin() const
{ {
return m_TextStyle.outlineJoin; return _TextStyle.outlineJoin;
} }
int e2d::Text::getLineCount() const int e2d::Text::getLineCount() const
{ {
if (m_pDWriteTextLayout) if (_pDWriteTextLayout)
{ {
DWRITE_TEXT_METRICS metrics; DWRITE_TEXT_METRICS metrics;
m_pDWriteTextLayout->GetMetrics(&metrics); _pDWriteTextLayout->GetMetrics(&metrics);
return static_cast<int>(metrics.lineCount); return static_cast<int>(metrics.lineCount);
} }
else else
@ -141,81 +141,81 @@ int e2d::Text::getLineCount() const
bool e2d::Text::isItalic() const bool e2d::Text::isItalic() const
{ {
return m_TextStyle.italic; return _TextStyle.italic;
} }
bool e2d::Text::hasStrikethrough() const bool e2d::Text::hasStrikethrough() const
{ {
return m_TextStyle.hasStrikethrough; return _TextStyle.hasStrikethrough;
} }
bool e2d::Text::hasUnderline() const bool e2d::Text::hasUnderline() const
{ {
return m_TextStyle.hasUnderline; return _TextStyle.hasUnderline;
} }
bool e2d::Text::hasOutline() const bool e2d::Text::hasOutline() const
{ {
return m_TextStyle.hasOutline; return _TextStyle.hasOutline;
} }
void e2d::Text::setText(const String& text) void e2d::Text::setText(const String& text)
{ {
m_sText = text; _sText = text;
_reset(); _reset();
} }
void e2d::Text::setTextStyle(TextStyle textStyle) void e2d::Text::setTextStyle(TextStyle textStyle)
{ {
m_TextStyle = textStyle; _TextStyle = textStyle;
_reset(); _reset();
} }
void e2d::Text::setFontFamily(const String& fontFamily) void e2d::Text::setFontFamily(const String& fontFamily)
{ {
m_TextStyle.fontFamily = fontFamily; _TextStyle.fontFamily = fontFamily;
_reset(); _reset();
} }
void e2d::Text::setFontSize(double fontSize) void e2d::Text::setFontSize(double fontSize)
{ {
m_TextStyle.fontSize = fontSize; _TextStyle.fontSize = fontSize;
_reset(); _reset();
} }
void e2d::Text::setFontWeight(UINT32 fontWeight) void e2d::Text::setFontWeight(UINT32 fontWeight)
{ {
m_TextStyle.fontWeight = fontWeight; _TextStyle.fontWeight = fontWeight;
_reset(); _reset();
} }
void e2d::Text::setColor(Color color) void e2d::Text::setColor(Color color)
{ {
m_TextStyle.color = color; _TextStyle.color = color;
} }
void e2d::Text::setItalic(bool value) void e2d::Text::setItalic(bool value)
{ {
m_TextStyle.italic = value; _TextStyle.italic = value;
_reset(); _reset();
} }
void e2d::Text::setWrapping(bool wrapping) void e2d::Text::setWrapping(bool wrapping)
{ {
if (m_TextStyle.wrapping != wrapping) if (_TextStyle.wrapping != wrapping)
{ {
m_TextStyle.wrapping = wrapping; _TextStyle.wrapping = wrapping;
_reset(); _reset();
} }
} }
void e2d::Text::setWrappingWidth(double fWrappingWidth) 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(); _reset();
} }
@ -224,28 +224,28 @@ void e2d::Text::setWrappingWidth(double fWrappingWidth)
void e2d::Text::setLineSpacing(double fLineSpacing) void e2d::Text::setLineSpacing(double fLineSpacing)
{ {
if (m_TextStyle.lineSpacing != fLineSpacing) if (_TextStyle.lineSpacing != fLineSpacing)
{ {
m_TextStyle.lineSpacing = fLineSpacing; _TextStyle.lineSpacing = fLineSpacing;
_reset(); _reset();
} }
} }
void e2d::Text::setAlignment(TextAlign align) void e2d::Text::setAlignment(TextAlign align)
{ {
if (m_TextStyle.alignment != align) if (_TextStyle.alignment != align)
{ {
m_TextStyle.alignment = align; _TextStyle.alignment = align;
_reset(); _reset();
} }
} }
void e2d::Text::setUnderline(bool hasUnderline) void e2d::Text::setUnderline(bool hasUnderline)
{ {
if (m_TextStyle.hasUnderline != hasUnderline) if (_TextStyle.hasUnderline != hasUnderline)
{ {
m_TextStyle.hasUnderline = hasUnderline; _TextStyle.hasUnderline = hasUnderline;
if (!m_pDWriteTextFormat) if (!_pDWriteTextFormat)
_createFormat(); _createFormat();
_createLayout(); _createLayout();
} }
@ -253,10 +253,10 @@ void e2d::Text::setUnderline(bool hasUnderline)
void e2d::Text::setStrikethrough(bool hasStrikethrough) void e2d::Text::setStrikethrough(bool hasStrikethrough)
{ {
if (m_TextStyle.hasStrikethrough != hasStrikethrough) if (_TextStyle.hasStrikethrough != hasStrikethrough)
{ {
m_TextStyle.hasStrikethrough = hasStrikethrough; _TextStyle.hasStrikethrough = hasStrikethrough;
if (!m_pDWriteTextFormat) if (!_pDWriteTextFormat)
_createFormat(); _createFormat();
_createLayout(); _createLayout();
} }
@ -264,42 +264,42 @@ void e2d::Text::setStrikethrough(bool hasStrikethrough)
void e2d::Text::setOutline(bool hasOutline) void e2d::Text::setOutline(bool hasOutline)
{ {
m_TextStyle.hasOutline = hasOutline; _TextStyle.hasOutline = hasOutline;
} }
void e2d::Text::setOutlineColor(Color outlineColor) void e2d::Text::setOutlineColor(Color outlineColor)
{ {
m_TextStyle.outlineColor = outlineColor; _TextStyle.outlineColor = outlineColor;
} }
void e2d::Text::setOutlineWidth(double outlineWidth) void e2d::Text::setOutlineWidth(double outlineWidth)
{ {
m_TextStyle.outlineWidth = outlineWidth; _TextStyle.outlineWidth = outlineWidth;
} }
void e2d::Text::setOutlineJoin(LineJoin outlineJoin) void e2d::Text::setOutlineJoin(LineJoin outlineJoin)
{ {
m_TextStyle.outlineJoin = outlineJoin; _TextStyle.outlineJoin = outlineJoin;
} }
void e2d::Text::onRender() 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(); auto pTextRenderer = Renderer::getCustomTextRenderer();
pTextRenderer->SetTextStyle( pTextRenderer->SetTextStyle(
m_TextStyle.color.toColorF(), _TextStyle.color.toColorF(),
m_TextStyle.hasOutline, _TextStyle.hasOutline,
m_TextStyle.outlineColor.toColorF(), _TextStyle.outlineColor.toColorF(),
static_cast<FLOAT>(m_TextStyle.outlineWidth), static_cast<FLOAT>(_TextStyle.outlineWidth),
D2D1_LINE_JOIN(m_TextStyle.outlineJoin) 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() void e2d::Text::_createFormat()
{ {
SafeReleaseInterface(&m_pDWriteTextFormat); SafeReleaseInterface(&_pDWriteTextFormat);
HRESULT hr = Renderer::getIDWriteFactory()->CreateTextFormat( HRESULT hr = Renderer::getIDWriteFactory()->CreateTextFormat(
m_TextStyle.fontFamily, _TextStyle.fontFamily,
NULL, NULL,
DWRITE_FONT_WEIGHT(m_TextStyle.fontWeight), DWRITE_FONT_WEIGHT(_TextStyle.fontWeight),
m_TextStyle.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, _TextStyle.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
static_cast<float>(m_TextStyle.fontSize), static_cast<float>(_TextStyle.fontSize),
L"", L"",
&m_pDWriteTextFormat &_pDWriteTextFormat
); );
ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!"); 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 else
{ {
m_pDWriteTextFormat->SetLineSpacing( _pDWriteTextFormat->SetLineSpacing(
DWRITE_LINE_SPACING_METHOD_UNIFORM, DWRITE_LINE_SPACING_METHOD_UNIFORM,
static_cast<FLOAT>(m_TextStyle.lineSpacing), static_cast<FLOAT>(_TextStyle.lineSpacing),
static_cast<FLOAT>(m_TextStyle.lineSpacing) * 0.8f 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 else
{ {
m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); _pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
} }
} }
} }
void e2d::Text::_createLayout() void e2d::Text::_createLayout()
{ {
SafeReleaseInterface(&m_pDWriteTextLayout); SafeReleaseInterface(&_pDWriteTextLayout);
// 文本为空字符串时,重置属性 // 文本为空字符串时,重置属性
if (m_sText.isEmpty()) if (_sText.isEmpty())
{ {
this->setSize(0, 0); this->setSize(0, 0);
return; 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; return;
} }
UINT32 length = static_cast<UINT32>(m_sText.getLength()); UINT32 length = static_cast<UINT32>(_sText.getLength());
// 创建 TextLayout // 创建 TextLayout
HRESULT hr; HRESULT hr;
// 对文本自动换行情况下进行处理 // 对文本自动换行情况下进行处理
if (m_TextStyle.wrapping) if (_TextStyle.wrapping)
{ {
hr = Renderer::getIDWriteFactory()->CreateTextLayout( hr = Renderer::getIDWriteFactory()->CreateTextLayout(
m_sText, _sText,
length, length,
m_pDWriteTextFormat, _pDWriteTextFormat,
static_cast<FLOAT>(m_TextStyle.wrappingWidth), static_cast<FLOAT>(_TextStyle.wrappingWidth),
0, 0,
&m_pDWriteTextLayout &_pDWriteTextLayout
); );
if (m_pDWriteTextLayout) if (_pDWriteTextLayout)
{ {
// 获取文本布局的宽度和高度 // 获取文本布局的宽度和高度
DWRITE_TEXT_METRICS metrics; DWRITE_TEXT_METRICS metrics;
m_pDWriteTextLayout->GetMetrics(&metrics); _pDWriteTextLayout->GetMetrics(&metrics);
// 重设文本宽高 // 重设文本宽高
this->setSize(metrics.layoutWidth, metrics.height); this->setSize(metrics.layoutWidth, metrics.height);
} }
} }
else 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 宽度重新创建它 // 为防止文本对齐问题,根据刚才创建的 layout 宽度重新创建它
if (m_pDWriteTextLayout) if (_pDWriteTextLayout)
{ {
// 获取文本布局的宽度和高度 // 获取文本布局的宽度和高度
DWRITE_TEXT_METRICS metrics; DWRITE_TEXT_METRICS metrics;
m_pDWriteTextLayout->GetMetrics(&metrics); _pDWriteTextLayout->GetMetrics(&metrics);
// 重设文本宽高 // 重设文本宽高
this->setSize(metrics.width, metrics.height); this->setSize(metrics.width, metrics.height);
// 重新创建 layout // 重新创建 layout
SafeReleaseInterface(&m_pDWriteTextLayout); SafeReleaseInterface(&_pDWriteTextLayout);
hr = Renderer::getIDWriteFactory()->CreateTextLayout(m_sText, length, m_pDWriteTextFormat, m_fWidth, 0, &m_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 }; 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);
} }
} }

View File

@ -79,16 +79,16 @@ protected:
); );
protected: protected:
bool m_bOpened; bool _bOpened;
mutable bool m_bPlaying; mutable bool _bPlaying;
DWORD m_dwSize; DWORD _dwSize;
CHAR* m_pResourceBuffer; CHAR* _pResourceBuffer;
BYTE* m_pbWaveData; BYTE* _pbWaveData;
HMMIO m_hmmio; HMMIO _hmmio;
MMCKINFO m_ck; MMCKINFO _ck;
MMCKINFO m_ckRiff; MMCKINFO _ckRiff;
WAVEFORMATEX* m_pwfx; WAVEFORMATEX* _pwfx;
IXAudio2SourceVoice* m_pSourceVoice; IXAudio2SourceVoice* _pSourceVoice;
}; };
typedef std::map<UINT, MusicPlayer *> MusicMap; typedef std::map<UINT, MusicPlayer *> MusicMap;
@ -106,14 +106,14 @@ static MusicMap& GetMusicResList()
} }
MusicPlayer::MusicPlayer() MusicPlayer::MusicPlayer()
: m_bOpened(false) : _bOpened(false)
, m_bPlaying(false) , _bPlaying(false)
, m_pwfx(nullptr) , _pwfx(nullptr)
, m_hmmio(nullptr) , _hmmio(nullptr)
, m_pResourceBuffer(nullptr) , _pResourceBuffer(nullptr)
, m_pbWaveData(nullptr) , _pbWaveData(nullptr)
, m_dwSize(0) , _dwSize(0)
, m_pSourceVoice(nullptr) , _pSourceVoice(nullptr)
{ {
} }
@ -124,7 +124,7 @@ MusicPlayer::~MusicPlayer()
bool MusicPlayer::open(const e2d::String& filePath) bool MusicPlayer::open(const e2d::String& filePath)
{ {
if (m_bOpened) if (_bOpened)
{ {
WARN_IF(true, "MusicInfo can be opened only once!"); WARN_IF(true, "MusicInfo can be opened only once!");
return false; return false;
@ -150,9 +150,9 @@ bool MusicPlayer::open(const e2d::String& filePath)
return false; 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"); return TraceError(L"mmioOpen");
} }
@ -160,37 +160,37 @@ bool MusicPlayer::open(const e2d::String& filePath)
if (!_readMMIO()) if (!_readMMIO())
{ {
// 读取非 wave 文件时 ReadMMIO 调用失败 // 读取非 wave 文件时 ReadMMIO 调用失败
mmioClose(m_hmmio, 0); mmioClose(_hmmio, 0);
return TraceError(L"_readMMIO"); return TraceError(L"_readMMIO");
} }
if (!_resetFile()) if (!_resetFile())
return TraceError(L"_resetFile"); return TraceError(L"_resetFile");
// 重置文件后wave 文件的大小是 m_ck.cksize // 重置文件后wave 文件的大小是 _ck.cksize
m_dwSize = m_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"); TraceError(L"Failed to read WAV data");
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
return false; return false;
} }
// 创建音源 // 创建音源
HRESULT hr; 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); TraceError(L"Create source voice error", hr);
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
return false; return false;
} }
m_bOpened = true; _bOpened = true;
m_bPlaying = false; _bPlaying = false;
return true; return true;
} }
@ -201,7 +201,7 @@ bool MusicPlayer::open(int resNameId, const e2d::String& resType)
DWORD dwSize; DWORD dwSize;
void* pvRes; void* pvRes;
if (m_bOpened) if (_bOpened)
{ {
WARN_IF(true, "MusicInfo can be opened only once!"); WARN_IF(true, "MusicInfo can be opened only once!");
return false; return false;
@ -226,69 +226,69 @@ bool MusicPlayer::open(int resNameId, const e2d::String& resType)
if (nullptr == (pvRes = LockResource(hResData))) if (nullptr == (pvRes = LockResource(hResData)))
return TraceError(L"LockResource"); return TraceError(L"LockResource");
m_pResourceBuffer = new CHAR[dwSize]; _pResourceBuffer = new CHAR[dwSize];
memcpy(m_pResourceBuffer, pvRes, dwSize); memcpy(_pResourceBuffer, pvRes, dwSize);
MMIOINFO mmioInfo; MMIOINFO mmioInfo;
ZeroMemory(&mmioInfo, sizeof(mmioInfo)); ZeroMemory(&mmioInfo, sizeof(mmioInfo));
mmioInfo.fccIOProc = FOURCC_MEM; mmioInfo.fccIOProc = FOURCC_MEM;
mmioInfo.cchBuffer = dwSize; 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()) if (!_readMMIO())
{ {
// ReadMMIO will fail if its an not a wave file // ReadMMIO will fail if its an not a wave file
mmioClose(m_hmmio, 0); mmioClose(_hmmio, 0);
return TraceError(L"ReadMMIO"); return TraceError(L"ReadMMIO");
} }
if (!_resetFile()) if (!_resetFile())
return TraceError(L"ResetFile"); return TraceError(L"ResetFile");
// After the reset, the size of the wav file is m_ck.cksize so store it now // After the reset, the size of the wav file is _ck.cksize so store it now
m_dwSize = m_ck.cksize; _dwSize = _ck.cksize;
// Read the sample data into memory // 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"); TraceError(L"Failed to read WAV data");
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
return false; return false;
} }
// 创建音源 // 创建音源
HRESULT hr; 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); TraceError(L"Create source voice error", hr);
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
return false; return false;
} }
m_bOpened = true; _bOpened = true;
m_bPlaying = false; _bPlaying = false;
return true; return true;
} }
bool MusicPlayer::play(int nLoopCount) bool MusicPlayer::play(int nLoopCount)
{ {
if (!m_bOpened) if (!_bOpened)
{ {
WARN_IF(true, "MusicInfo::play Failed: MusicInfo must be opened first!"); WARN_IF(true, "MusicInfo::play Failed: MusicInfo must be opened first!");
return false; return false;
} }
if (m_pSourceVoice == nullptr) if (_pSourceVoice == nullptr)
{ {
WARN_IF(true, "MusicInfo::play Failed: IXAudio2SourceVoice Null pointer exception!"); WARN_IF(true, "MusicInfo::play Failed: IXAudio2SourceVoice Null pointer exception!");
return false; return false;
} }
if (m_bPlaying) if (_bPlaying)
{ {
stop(); stop();
} }
@ -298,23 +298,23 @@ bool MusicPlayer::play(int nLoopCount)
// 提交 wave 样本数据 // 提交 wave 样本数据
XAUDIO2_BUFFER buffer = { 0 }; XAUDIO2_BUFFER buffer = { 0 };
buffer.pAudioData = m_pbWaveData; buffer.pAudioData = _pbWaveData;
buffer.Flags = XAUDIO2_END_OF_STREAM; buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.AudioBytes = m_dwSize; buffer.AudioBytes = _dwSize;
buffer.LoopCount = nLoopCount; buffer.LoopCount = nLoopCount;
HRESULT hr; HRESULT hr;
if (FAILED(hr = m_pSourceVoice->SubmitSourceBuffer(&buffer))) if (FAILED(hr = _pSourceVoice->SubmitSourceBuffer(&buffer)))
{ {
TraceError(L"Submitting source buffer error", hr); TraceError(L"Submitting source buffer error", hr);
m_pSourceVoice->DestroyVoice(); _pSourceVoice->DestroyVoice();
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
return false; return false;
} }
if (SUCCEEDED(hr = m_pSourceVoice->Start(0))) if (SUCCEEDED(hr = _pSourceVoice->Start(0)))
{ {
m_bPlaying = true; _bPlaying = true;
} }
return SUCCEEDED(hr); return SUCCEEDED(hr);
@ -322,75 +322,75 @@ bool MusicPlayer::play(int nLoopCount)
void MusicPlayer::pause() 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() 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() void MusicPlayer::stop()
{ {
if (m_pSourceVoice) if (_pSourceVoice)
{ {
if (SUCCEEDED(m_pSourceVoice->Stop())) if (SUCCEEDED(_pSourceVoice->Stop()))
{ {
m_pSourceVoice->ExitLoop(); _pSourceVoice->ExitLoop();
m_pSourceVoice->FlushSourceBuffers(); _pSourceVoice->FlushSourceBuffers();
m_bPlaying = false; _bPlaying = false;
} }
} }
} }
void MusicPlayer::close() void MusicPlayer::close()
{ {
if (m_pSourceVoice) if (_pSourceVoice)
{ {
m_pSourceVoice->Stop(); _pSourceVoice->Stop();
m_pSourceVoice->FlushSourceBuffers(); _pSourceVoice->FlushSourceBuffers();
m_pSourceVoice->DestroyVoice(); _pSourceVoice->DestroyVoice();
m_pSourceVoice = nullptr; _pSourceVoice = nullptr;
} }
if (m_hmmio != nullptr) if (_hmmio != nullptr)
{ {
mmioClose(m_hmmio, 0); mmioClose(_hmmio, 0);
m_hmmio = nullptr; _hmmio = nullptr;
} }
SAFE_DELETE_ARRAY(m_pResourceBuffer); SAFE_DELETE_ARRAY(_pResourceBuffer);
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(_pbWaveData);
SAFE_DELETE_ARRAY(m_pwfx); SAFE_DELETE_ARRAY(_pwfx);
m_bOpened = false; _bOpened = false;
m_bPlaying = false; _bPlaying = false;
} }
bool MusicPlayer::isPlaying() const bool MusicPlayer::isPlaying() const
{ {
if (m_bOpened && m_pSourceVoice) if (_bOpened && _pSourceVoice)
{ {
XAUDIO2_VOICE_STATE state; XAUDIO2_VOICE_STATE state;
m_pSourceVoice->GetState(&state); _pSourceVoice->GetState(&state);
if (state.BuffersQueued == 0) if (state.BuffersQueued == 0)
{ {
m_bPlaying = false; _bPlaying = false;
} }
return m_bPlaying; return _bPlaying;
} }
else else
{ {
@ -400,9 +400,9 @@ bool MusicPlayer::isPlaying() const
bool MusicPlayer::setVolume(float fVolume) bool MusicPlayer::setVolume(float fVolume)
{ {
if (m_pSourceVoice) if (_pSourceVoice)
{ {
return SUCCEEDED(m_pSourceVoice->SetVolume(fVolume)); return SUCCEEDED(_pSourceVoice->SetVolume(fVolume));
} }
return false; return false;
} }
@ -414,19 +414,19 @@ bool MusicPlayer::_readMMIO()
memset(&ckIn, 0, sizeof(ckIn)); 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"); return TraceError(L"mmioDescend");
// 确认文件是一个合法的 wave 文件 // 确认文件是一个合法的 wave 文件
if ((m_ckRiff.ckid != FOURCC_RIFF) || if ((_ckRiff.ckid != FOURCC_RIFF) ||
(m_ckRiff.fccType != mmioFOURCC('W', 'A', 'V', 'E'))) (_ckRiff.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
return TraceError(L"mmioFOURCC"); return TraceError(L"mmioFOURCC");
// 在输入文件中查找 'fmt' 块 // 在输入文件中查找 'fmt' 块
ckIn.ckid = mmioFOURCC('f', 'm', 't', ' '); 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"); return TraceError(L"mmioDescend");
// 'fmt' 块至少应和 PCMWAVEFORMAT 一样大 // 'fmt' 块至少应和 PCMWAVEFORMAT 一样大
@ -434,7 +434,7 @@ bool MusicPlayer::_readMMIO()
return TraceError(L"sizeof(PCMWAVEFORMAT)"); return TraceError(L"sizeof(PCMWAVEFORMAT)");
// 将 'fmt' 块读取到 pcmWaveFormat 中 // 将 'fmt' 块读取到 pcmWaveFormat 中
if (mmioRead(m_hmmio, (HPSTR)&pcmWaveFormat, if (mmioRead(_hmmio, (HPSTR)&pcmWaveFormat,
sizeof(pcmWaveFormat)) != sizeof(pcmWaveFormat)) sizeof(pcmWaveFormat)) != sizeof(pcmWaveFormat))
return TraceError(L"mmioRead"); return TraceError(L"mmioRead");
@ -442,37 +442,37 @@ bool MusicPlayer::_readMMIO()
// 的数据,这个数据就是额外分配的大小 // 的数据,这个数据就是额外分配的大小
if (pcmWaveFormat.wf.wFormatTag == WAVE_FORMAT_PCM) 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)); memcpy(_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
m_pwfx->cbSize = 0; _pwfx->cbSize = 0;
} }
else else
{ {
// 读取额外数据的大小 // 读取额外数据的大小
WORD cbExtraBytes = 0L; 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"); 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)); memcpy(_pwfx, &pcmWaveFormat, sizeof(pcmWaveFormat));
m_pwfx->cbSize = cbExtraBytes; _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) cbExtraBytes) != cbExtraBytes)
{ {
SAFE_DELETE(m_pwfx); SAFE_DELETE(_pwfx);
return TraceError(L"mmioRead"); 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"); return TraceError(L"mmioAscend");
} }
@ -482,13 +482,13 @@ bool MusicPlayer::_readMMIO()
bool MusicPlayer::_resetFile() bool MusicPlayer::_resetFile()
{ {
// Seek to the data // Seek to the data
if (-1 == mmioSeek(m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC), if (-1 == mmioSeek(_hmmio, _ckRiff.dwDataOffset + sizeof(FOURCC),
SEEK_SET)) SEEK_SET))
return TraceError(L"mmioSeek"); return TraceError(L"mmioSeek");
// Search the input file for the 'data' chunk. // Search the input file for the 'data' chunk.
m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a'); _ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
if (0 != mmioDescend(m_hmmio, &m_ck, &m_ckRiff, MMIO_FINDCHUNK)) if (0 != mmioDescend(_hmmio, &_ck, &_ckRiff, MMIO_FINDCHUNK))
return TraceError(L"mmioDescend"); return TraceError(L"mmioDescend");
return true; return true;
@ -496,23 +496,23 @@ bool MusicPlayer::_resetFile()
bool MusicPlayer::_read(BYTE* pBuffer, DWORD dwSizeToRead) 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"); return TraceError(L"mmioGetInfo");
UINT cbDataIn = dwSizeToRead; UINT cbDataIn = dwSizeToRead;
if (cbDataIn > m_ck.cksize) if (cbDataIn > _ck.cksize)
cbDataIn = m_ck.cksize; cbDataIn = _ck.cksize;
m_ck.cksize -= cbDataIn; _ck.cksize -= cbDataIn;
for (DWORD cT = 0; cT < cbDataIn; cT++) for (DWORD cT = 0; cT < cbDataIn; cT++)
{ {
// Copy the bytes from the io to the buffer. // Copy the bytes from the io to the buffer.
if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead) if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead)
{ {
if (0 != mmioAdvance(m_hmmio, &mmioinfoIn, MMIO_READ)) if (0 != mmioAdvance(_hmmio, &mmioinfoIn, MMIO_READ))
return TraceError(L"mmioAdvance"); return TraceError(L"mmioAdvance");
if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead) if (mmioinfoIn.pchNext == mmioinfoIn.pchEndRead)
@ -524,7 +524,7 @@ bool MusicPlayer::_read(BYTE* pBuffer, DWORD dwSizeToRead)
mmioinfoIn.pchNext++; mmioinfoIn.pchNext++;
} }
if (0 != mmioSetInfo(m_hmmio, &mmioinfoIn, 0)) if (0 != mmioSetInfo(_hmmio, &mmioinfoIn, 0))
return TraceError(L"mmioSetInfo"); return TraceError(L"mmioSetInfo");
return true; return true;

View File

@ -3,44 +3,44 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::TransitionBase::TransitionBase(double duration) e2d::TransitionBase::TransitionBase(double duration)
: m_bEnd(false) : _bEnd(false)
, m_fLast(0) , _fLast(0)
, m_fRateOfProgress(0) , _fRateOfProgress(0)
, m_pPrevScene(nullptr) , _pPrevScene(nullptr)
, m_pNextScene(nullptr) , _pNextScene(nullptr)
, m_pPrevLayer(nullptr) , _pPrevLayer(nullptr)
, m_pNextLayer(nullptr) , _pNextLayer(nullptr)
, m_sPrevLayerParam() , _sPrevLayerParam()
, m_sNextLayerParam() , _sNextLayerParam()
{ {
m_fDuration = max(duration, 0); _fDuration = max(duration, 0);
} }
e2d::TransitionBase::~TransitionBase() e2d::TransitionBase::~TransitionBase()
{ {
SafeReleaseInterface(&m_pPrevLayer); SafeReleaseInterface(&_pPrevLayer);
SafeReleaseInterface(&m_pNextLayer); SafeReleaseInterface(&_pNextLayer);
} }
bool e2d::TransitionBase::isDone() bool e2d::TransitionBase::isDone()
{ {
return m_bEnd; return _bEnd;
} }
void e2d::TransitionBase::destroy() void e2d::TransitionBase::destroy()
{ {
SafeRelease(&m_pPrevScene); SafeRelease(&_pPrevScene);
SafeRelease(&m_pNextScene); SafeRelease(&_pNextScene);
} }
void e2d::TransitionBase::_init(Scene * prev, Scene * next) void e2d::TransitionBase::_init(Scene * prev, Scene * next)
{ {
// 创建图层 // 创建图层
HRESULT hr = Renderer::getRenderTarget()->CreateLayer(&m_pNextLayer); HRESULT hr = Renderer::getRenderTarget()->CreateLayer(&_pNextLayer);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = Renderer::getRenderTarget()->CreateLayer(&m_pPrevLayer); hr = Renderer::getRenderTarget()->CreateLayer(&_pPrevLayer);
} }
if (FAILED(hr)) if (FAILED(hr))
@ -48,38 +48,38 @@ void e2d::TransitionBase::_init(Scene * prev, Scene * next)
ASSERT(false, "Create layer failed!"); ASSERT(false, "Create layer failed!");
} }
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
m_pPrevScene = prev; _pPrevScene = prev;
m_pNextScene = next; _pNextScene = next;
if (m_pPrevScene) m_pPrevScene->retain(); if (_pPrevScene) _pPrevScene->retain();
if (m_pNextScene) m_pNextScene->retain(); if (_pNextScene) _pNextScene->retain();
m_WindowSize = Window::getSize(); _WindowSize = Window::getSize();
m_sPrevLayerParam = m_sNextLayerParam = D2D1::LayerParameters(); _sPrevLayerParam = _sNextLayerParam = D2D1::LayerParameters();
} }
void e2d::TransitionBase::_update() void e2d::TransitionBase::_update()
{ {
// 计算动画进度 // 计算动画进度
if (m_fDuration == 0) if (_fDuration == 0)
{ {
m_fRateOfProgress = 1; _fRateOfProgress = 1;
} }
else else
{ {
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1); _fRateOfProgress = min((Time::getTotalTime() - _fLast) / _fDuration, 1);
} }
this->_updateCustom(); 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(); auto pRT = Renderer::getRenderTarget();
if (m_pPrevScene) if (_pPrevScene)
{ {
Point rootPos = m_pPrevScene->getRoot()->getPos(); Point rootPos = _pPrevScene->getRoot()->getPos();
auto clipRect = D2D1::RectF( auto clipRect = D2D1::RectF(
float(max(rootPos.x, 0)), float(max(rootPos.x, 0)),
float(max(rootPos.y, 0)), float(max(rootPos.y, 0)),
float(min(rootPos.x + m_WindowSize.width, m_WindowSize.width)), float(min(rootPos.x + _WindowSize.width, _WindowSize.width)),
float(min(rootPos.y + m_WindowSize.height, m_WindowSize.height)) float(min(rootPos.y + _WindowSize.height, _WindowSize.height))
); );
pRT->SetTransform(D2D1::Matrix3x2F::Identity()); pRT->SetTransform(D2D1::Matrix3x2F::Identity());
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); 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->PopLayer();
pRT->PopAxisAlignedClip(); pRT->PopAxisAlignedClip();
} }
if (m_pNextScene) if (_pNextScene)
{ {
Point rootPos = m_pNextScene->getRoot()->getPos(); Point rootPos = _pNextScene->getRoot()->getPos();
auto clipRect = D2D1::RectF( auto clipRect = D2D1::RectF(
float(max(rootPos.x, 0)), float(max(rootPos.x, 0)),
float(max(rootPos.y, 0)), float(max(rootPos.y, 0)),
float(min(rootPos.x + m_WindowSize.width, m_WindowSize.width)), float(min(rootPos.x + _WindowSize.width, _WindowSize.width)),
float(min(rootPos.y + m_WindowSize.height, m_WindowSize.height)) float(min(rootPos.y + _WindowSize.height, _WindowSize.height))
); );
pRT->SetTransform(D2D1::Matrix3x2F::Identity()); pRT->SetTransform(D2D1::Matrix3x2F::Identity());
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); 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->PopLayer();
pRT->PopAxisAlignedClip(); pRT->PopAxisAlignedClip();
@ -130,6 +130,6 @@ void e2d::TransitionBase::_render()
void e2d::TransitionBase::_stop() void e2d::TransitionBase::_stop()
{ {
m_bEnd = true; _bEnd = true;
_reset(); _reset();
} }

View File

@ -9,16 +9,16 @@ e2d::TransitionEmerge::TransitionEmerge(double duration)
void e2d::TransitionEmerge::_init(Scene * prev, Scene * next) void e2d::TransitionEmerge::_init(Scene * prev, Scene * next)
{ {
TransitionBase::_init(prev, next); TransitionBase::_init(prev, next);
m_sPrevLayerParam.opacity = 1; _sPrevLayerParam.opacity = 1;
m_sNextLayerParam.opacity = 0; _sNextLayerParam.opacity = 0;
} }
void e2d::TransitionEmerge::_updateCustom() void e2d::TransitionEmerge::_updateCustom()
{ {
m_sPrevLayerParam.opacity = float(1 - m_fRateOfProgress); _sPrevLayerParam.opacity = float(1 - _fRateOfProgress);
m_sNextLayerParam.opacity = float(m_fRateOfProgress); _sNextLayerParam.opacity = float(_fRateOfProgress);
if (m_fRateOfProgress >= 1) if (_fRateOfProgress >= 1)
{ {
this->_stop(); this->_stop();
} }

View File

@ -3,53 +3,53 @@
e2d::TransitionFade::TransitionFade(double duration) e2d::TransitionFade::TransitionFade(double duration)
: TransitionBase(0) : TransitionBase(0)
, m_fFadeOutDuration(max(duration / 2, 0)) , _fFadeOutDuration(max(duration / 2, 0))
, m_fFadeInDuration(max(duration / 2, 0)) , _fFadeInDuration(max(duration / 2, 0))
, m_bFadeOutTransioning(true) , _bFadeOutTransioning(true)
{ {
} }
e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration) e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration)
: TransitionBase(0) : TransitionBase(0)
, m_fFadeOutDuration(max(fadeOutDuration, 0)) , _fFadeOutDuration(max(fadeOutDuration, 0))
, m_fFadeInDuration(max(fadeInDuration, 0)) , _fFadeInDuration(max(fadeInDuration, 0))
, m_bFadeOutTransioning(true) , _bFadeOutTransioning(true)
{ {
} }
void e2d::TransitionFade::_init(Scene * prev, Scene * next) void e2d::TransitionFade::_init(Scene * prev, Scene * next)
{ {
TransitionBase::_init(prev, next); TransitionBase::_init(prev, next);
if (m_pPrevScene) if (_pPrevScene)
{ {
m_bFadeOutTransioning = true; _bFadeOutTransioning = true;
m_fDuration = m_fFadeOutDuration; _fDuration = _fFadeOutDuration;
} }
else else
{ {
m_bFadeOutTransioning = false; _bFadeOutTransioning = false;
m_fDuration = m_fFadeInDuration; _fDuration = _fFadeInDuration;
} }
m_sPrevLayerParam.opacity = 1; _sPrevLayerParam.opacity = 1;
m_sNextLayerParam.opacity = 0; _sNextLayerParam.opacity = 0;
} }
void e2d::TransitionFade::_updateCustom() void e2d::TransitionFade::_updateCustom()
{ {
if (m_bFadeOutTransioning) if (_bFadeOutTransioning)
{ {
m_sPrevLayerParam.opacity = float(1 - m_fRateOfProgress); _sPrevLayerParam.opacity = float(1 - _fRateOfProgress);
if (m_fRateOfProgress >= 1) if (_fRateOfProgress >= 1)
{ {
m_bFadeOutTransioning = false; _bFadeOutTransioning = false;
m_fDuration = m_fFadeInDuration; _fDuration = _fFadeInDuration;
m_fLast = Time::getTotalTime(); _fLast = Time::getTotalTime();
} }
} }
else else
{ {
m_sNextLayerParam.opacity = float(m_fRateOfProgress); _sNextLayerParam.opacity = float(_fRateOfProgress);
if (m_fRateOfProgress >= 1) if (_fRateOfProgress >= 1)
{ {
this->_stop(); this->_stop();
} }

View File

@ -3,7 +3,7 @@
e2d::TransitionMove::TransitionMove(double duration, Direct direct) e2d::TransitionMove::TransitionMove(double duration, Direct direct)
: TransitionBase(duration) : TransitionBase(duration)
, m_Direct(direct) , _Direct(direct)
{ {
} }
@ -11,45 +11,45 @@ void e2d::TransitionMove::_init(Scene * prev, Scene * next)
{ {
TransitionBase::_init(prev, next); TransitionBase::_init(prev, next);
double width = m_WindowSize.width; double width = _WindowSize.width;
double height = m_WindowSize.height; double height = _WindowSize.height;
if (m_Direct == Direct::UP) if (_Direct == Direct::UP)
{ {
m_Vector = Vector(0, -height); _Vector = Vector(0, -height);
m_NextPos = Point(0, height); _NextPos = Point(0, height);
} }
else if (m_Direct == Direct::DOWN) else if (_Direct == Direct::DOWN)
{ {
m_Vector = Vector(0, height); _Vector = Vector(0, height);
m_NextPos = Point(0, -height); _NextPos = Point(0, -height);
} }
else if (m_Direct == Direct::LEFT) else if (_Direct == Direct::LEFT)
{ {
m_Vector = Vector(-width, 0); _Vector = Vector(-width, 0);
m_NextPos = Point(width, 0); _NextPos = Point(width, 0);
} }
else if (m_Direct == Direct::RIGHT) else if (_Direct == Direct::RIGHT)
{ {
m_Vector = Vector(width, 0); _Vector = Vector(width, 0);
m_NextPos = Point(-width, 0); _NextPos = Point(-width, 0);
} }
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0); if (_pPrevScene) _pPrevScene->getRoot()->setPos(0, 0);
m_pNextScene->getRoot()->setPos(m_NextPos); _pNextScene->getRoot()->setPos(_NextPos);
} }
void e2d::TransitionMove::_updateCustom() 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(); this->_stop();
} }
@ -57,7 +57,7 @@ void e2d::TransitionMove::_updateCustom()
void e2d::TransitionMove::_reset() void e2d::TransitionMove::_reset()
{ {
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0); if (_pPrevScene) _pPrevScene->getRoot()->setPos(0, 0);
m_pNextScene->getRoot()->setPos(0, 0); _pNextScene->getRoot()->setPos(0, 0);
} }

View File

@ -170,11 +170,6 @@ public:
// 获取动作运行状态 // 获取动作运行状态
virtual bool isRunning(); virtual bool isRunning();
// 开始动作
virtual void startWithTarget(
Node* target /* 执行该动作的目标 */
);
// 继续动作 // 继续动作
virtual void resume(); virtual void resume();
@ -192,12 +187,12 @@ public:
const String& name const String& name
); );
// 获取一个新的逆向动作 // 获取动作的拷贝
virtual ActionBase * reverse() const;
// 获取一个新的拷贝动作
virtual ActionBase * clone() const = 0; virtual ActionBase * clone() const = 0;
// 获取动作的倒转
virtual ActionBase * reverse() const;
// 重置动作 // 重置动作
virtual void reset(); virtual void reset();
@ -220,14 +215,19 @@ protected:
// 重置动画时间 // 重置动画时间
virtual void _resetTime(); virtual void _resetTime();
// 开始动作
virtual void _startWithTarget(
Node* target
);
protected: protected:
String m_sName; String _sName;
bool m_bRunning; bool _bRunning;
bool m_bEnding; bool _bEnding;
bool m_bInit; bool _bInit;
Node * m_pTarget; Node * _pTarget;
Scene * m_pParentScene; Scene * _pParentScene;
double m_fLast; double _fLast;
}; };
@ -249,8 +249,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_fDuration; double _fDuration;
double m_fRateOfProgress; double _fRateOfProgress;
}; };
@ -268,7 +268,7 @@ public:
// 获取该动画的拷贝对象 // 获取该动画的拷贝对象
virtual ActionMoveBy * clone() const override; virtual ActionMoveBy * clone() const override;
// 获取该动画的逆动画 // 获取该动画的倒转
virtual ActionMoveBy * reverse() const override; virtual ActionMoveBy * reverse() const override;
protected: protected:
@ -279,8 +279,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
Point m_BeginPos; Point _BeginPos;
Vector m_MoveVec; Vector _MoveVec;
}; };
@ -303,7 +303,7 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
Point m_EndPos; Point _EndPos;
}; };
@ -328,7 +328,7 @@ public:
// 获取该动画的拷贝对象 // 获取该动画的拷贝对象
virtual ActionScaleBy * clone() const override; virtual ActionScaleBy * clone() const override;
// 获取该动画的逆动画 // 获取该动画的倒转
virtual ActionScaleBy * reverse() const override; virtual ActionScaleBy * reverse() const override;
protected: protected:
@ -339,10 +339,10 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_nBeginScaleX; double _nBeginScaleX;
double m_nBeginScaleY; double _nBeginScaleY;
double m_nVariationX; double _nVariationX;
double m_nVariationY; double _nVariationY;
}; };
@ -372,8 +372,8 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double m_nEndScaleX; double _nEndScaleX;
double m_nEndScaleY; double _nEndScaleY;
}; };
@ -391,7 +391,7 @@ public:
// 获取该动画的拷贝对象 // 获取该动画的拷贝对象
virtual ActionOpacityBy * clone() const override; virtual ActionOpacityBy * clone() const override;
// 获取该动画的逆动画 // 获取该动画的倒转
virtual ActionOpacityBy * reverse() const override; virtual ActionOpacityBy * reverse() const override;
protected: protected:
@ -402,8 +402,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_nBeginVal; double _nBeginVal;
double m_nVariation; double _nVariation;
}; };
@ -426,7 +426,7 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double m_nEndVal; double _nEndVal;
}; };
@ -437,8 +437,11 @@ class ActionFadeIn :
public: public:
// 创建淡入动画 // 创建淡入动画
ActionFadeIn( ActionFadeIn(
double duration /* 动画持续时长 */ double duration /* 动画持续时长 */
) : ActionOpacityTo(duration, 1) {} )
: ActionOpacityTo(duration, 1)
{
}
}; };
@ -449,8 +452,11 @@ class ActionFadeOut :
public: public:
// 创建淡出动画 // 创建淡出动画
ActionFadeOut( ActionFadeOut(
double duration /* 动画持续时长 */ double duration /* 动画持续时长 */
) : ActionOpacityTo(duration, 0) {} )
: ActionOpacityTo(duration, 0)
{
}
}; };
@ -468,7 +474,7 @@ public:
// 获取该动画的拷贝对象 // 获取该动画的拷贝对象
virtual ActionRotateBy * clone() const override; virtual ActionRotateBy * clone() const override;
// 获取该动画的逆动画 // 获取该动画的倒转
virtual ActionRotateBy * reverse() const override; virtual ActionRotateBy * reverse() const override;
protected: protected:
@ -479,8 +485,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_nBeginVal; double _nBeginVal;
double m_nVariation; double _nVariation;
}; };
@ -503,7 +509,7 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double m_nEndVal; double _nEndVal;
}; };
@ -516,7 +522,7 @@ public:
ActionTwo( ActionTwo(
ActionBase * pActionFirst, /* 第一个动作 */ ActionBase * pActionFirst, /* 第一个动作 */
ActionBase * pActionSecond, /* 第二个动作 */ ActionBase * pActionSecond, /* 第二个动作 */
bool bAtSameTime = false /* 同时开始 */ bool bAtSameTime = false /* 同时开始 */
); );
virtual ~ActionTwo(); virtual ~ActionTwo();
@ -524,9 +530,9 @@ public:
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
virtual ActionTwo * clone() const override; virtual ActionTwo * clone() const override;
// 获取该动作的逆动作 // 获取该动作的倒转
virtual ActionTwo * reverse( virtual ActionTwo * reverse(
bool actionReverse = true /* 子动作是否执行逆动作 */ bool actionReverse = true /* 子动作是否倒转 */
) const; ) const;
// 重置动作 // 重置动作
@ -546,9 +552,9 @@ protected:
virtual void _resetTime() override; virtual void _resetTime() override;
protected: protected:
ActionBase* m_pFirstAction; ActionBase* _pFirstAction;
ActionBase* m_pSecondAction; ActionBase* _pSecondAction;
bool m_bAtSameTime; bool _bAtSameTime;
}; };
@ -568,7 +574,7 @@ public:
#else #else
// 创建顺序动作 // 创建顺序动作
ActionSequence( ActionSequence(
int number, /* 动作数量 */ int number, /* 动作数量 */
ActionBase * action, /* 第一个动作 */ ActionBase * action, /* 第一个动作 */
... ...
); );
@ -598,9 +604,9 @@ public:
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
virtual ActionSequence * clone() const override; virtual ActionSequence * clone() const override;
// 获取该动作的逆动作 // 获取该动作的倒转
virtual ActionSequence * reverse( virtual ActionSequence * reverse(
bool actionReverse = true /* 子动作是否执行逆动作 */ bool actionReverse = true /* 子动作是否倒转 */
) const; ) const;
// 重置动作 // 重置动作
@ -620,8 +626,8 @@ protected:
virtual void _resetTime() override; virtual void _resetTime() override;
protected: protected:
UINT m_nActionIndex; UINT _nActionIndex;
std::vector<ActionBase*> m_vActions; std::vector<ActionBase*> _vActions;
}; };
@ -646,7 +652,7 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_fDelayTime; double _fDelayTime;
}; };
@ -683,9 +689,9 @@ protected:
virtual void _resetTime() override; virtual void _resetTime() override;
protected: protected:
ActionBase * m_pAction; ActionBase * _pAction;
int m_nTimes; int _nTimes;
int m_nTotalTimes; int _nTotalTimes;
}; };
@ -759,7 +765,7 @@ public:
// 获取该动画的拷贝对象 // 获取该动画的拷贝对象
virtual Animation * clone() const override; virtual Animation * clone() const override;
// 获取该动画的逆动画 // 获取该动画的倒转
virtual Animation * reverse() const override; virtual Animation * reverse() const override;
// 重置动作 // 重置动作
@ -776,9 +782,9 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double m_fInterval; double _fInterval;
UINT m_nFrameIndex; UINT _nFrameIndex;
std::vector<Image*> m_vFrames; std::vector<Image*> _vFrames;
}; };
@ -803,7 +809,7 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
Function m_Callback; Function _Callback;
}; };

View File

@ -65,12 +65,12 @@ protected:
virtual void _render(); virtual void _render();
protected: protected:
bool m_bEnable; bool _bEnable;
bool m_bIsVisiable; bool _bIsVisiable;
bool m_bAutoResize; bool _bAutoResize;
Color m_nColor; Color _nColor;
Node * m_pParentNode; Node * _pParentNode;
ID2D1TransformedGeometry * m_pTransformedGeometry; ID2D1TransformedGeometry * _pTransformedGeometry;
}; };
@ -113,7 +113,7 @@ protected:
virtual void _resize(); virtual void _resize();
protected: protected:
ID2D1RectangleGeometry * m_pD2dRectangle; ID2D1RectangleGeometry * _pD2dRectangle;
}; };
@ -152,7 +152,7 @@ protected:
virtual void _resize(); virtual void _resize();
protected: protected:
ID2D1EllipseGeometry * m_pD2dCircle; ID2D1EllipseGeometry * _pD2dCircle;
}; };
@ -193,7 +193,7 @@ protected:
virtual void _resize(); virtual void _resize();
protected: protected:
ID2D1EllipseGeometry * m_pD2dEllipse; ID2D1EllipseGeometry * _pD2dEllipse;
}; };
} }

View File

@ -204,7 +204,7 @@ public:
friend std::wistream& operator>> (std::wistream &, String &); friend std::wistream& operator>> (std::wistream &, String &);
private: private:
std::wstring m_str; std::wstring _str;
}; };
@ -552,7 +552,7 @@ public:
); );
template<typename Func> template<typename Func>
Function(Func func) : m_func(func) {} Function(Func func) : _func(func) {}
template<typename Func, typename Object> template<typename Func, typename Object>
Function( Function(
@ -560,7 +560,7 @@ public:
Object&& obj Object&& obj
) )
{ {
m_func = std::bind(func, obj); _func = std::bind(func, obj);
} }
void operator() (void) const; void operator() (void) const;
@ -568,7 +568,7 @@ public:
operator bool() const; operator bool() const;
protected: protected:
std::function<void()> m_func; std::function<void()> _func;
}; };
@ -593,7 +593,7 @@ public:
virtual void destroy() {} virtual void destroy() {}
private: private:
int m_nRefCount; int _nRefCount;
}; };
@ -701,11 +701,11 @@ public:
static void clearCache(); static void clearCache();
protected: protected:
double m_fSourceCropX; double _fSourceCropX;
double m_fSourceCropY; double _fSourceCropY;
double m_fSourceCropWidth; double _fSourceCropWidth;
double m_fSourceCropHeight; double _fSourceCropHeight;
ID2D1Bitmap * m_pBitmap; ID2D1Bitmap * _pBitmap;
}; };
@ -799,11 +799,11 @@ protected:
void _update(); void _update();
protected: protected:
bool m_bAutoUpdate; bool _bAutoUpdate;
bool m_bSortNeeded; bool _bSortNeeded;
bool m_bWillSave; bool _bWillSave;
bool m_bColliderVisiable; bool _bColliderVisiable;
Node * m_pRoot; Node * _pRoot;
}; };

View File

@ -93,6 +93,13 @@ class ActionManager
friend ActionBase; friend ActionBase;
public: public:
// 执行动作
static void start(
ActionBase * action,
Node * target,
bool paused
);
// 继续名称相同的所有动作 // 继续名称相同的所有动作
static void resume( static void resume(
const String& strActionName const String& strActionName
@ -131,38 +138,32 @@ private:
// 添加动作 // 添加动作
static void __add( static void __add(
ActionBase * pAction ActionBase * action
); );
// 删除动作 // 删除动作
static void __remove( static void __remove(
ActionBase * pAction ActionBase * action
);
// 执行动作
static void __startAction(
ActionBase * pAction,
Node * pTargetNode
); );
// 继续绑定在节点上的所有动作 // 继续绑定在节点上的所有动作
static void __resumeAllBindedWith( static void __resumeAllBindedWith(
Node * pTargetNode Node * target
); );
// 暂停绑定在节点上的所有动作 // 暂停绑定在节点上的所有动作
static void __pauseAllBindedWith( static void __pauseAllBindedWith(
Node * pTargetNode Node * target
); );
// 停止绑定在节点上的所有动作 // 停止绑定在节点上的所有动作
static void __stopAllBindedWith( static void __stopAllBindedWith(
Node * pTargetNode Node * target
); );
// 清空绑定在节点上的所有动作 // 清空绑定在节点上的所有动作
static void __clearAllBindedWith( static void __clearAllBindedWith(
Node * pTargetNode Node * target
); );
// 重置所有动作状态 // 重置所有动作状态
@ -273,7 +274,7 @@ public:
// 判断碰撞是否由该节点引发 // 判断碰撞是否由该节点引发
// 如果是,返回与其相撞的节点指针,否则返回空 // 如果是,返回与其相撞的节点指针,否则返回空
static Node * isCausedBy( static Node * isCausedBy(
Node * pNode Node * node
); );
// 判断发生碰撞的节点名称是否相同 // 判断发生碰撞的节点名称是否相同

View File

@ -34,7 +34,7 @@ public:
// 碰撞处理 // 碰撞处理
virtual void onCollide( virtual void onCollide(
Node* pNode /* ·¢ÉúÅöײµÄ½Úµã */ Node* node /* ˇ˘ÉúĹöײľÄ˝Úľă */
) {} ) {}
// 获取节点显示状态 // 获取节点显示状态
@ -47,7 +47,7 @@ public:
// 判断两节点是否相交 // 判断两节点是否相交
virtual bool isIntersectWith( virtual bool isIntersectWith(
const Node * pNode const Node * node
) const; ) const;
// 获取节点名称 // 获取节点名称
@ -442,34 +442,34 @@ protected:
void _updateOpacity(); void _updateOpacity();
protected: protected:
String m_sName; String _sName;
unsigned m_nHashName; unsigned _nHashName;
float m_fPosX; float _fPosX;
float m_fPosY; float _fPosY;
float m_fWidth; float _fWidth;
float m_fHeight; float _fHeight;
float m_fScaleX; float _fScaleX;
float m_fScaleY; float _fScaleY;
float m_fRotation; float _fRotation;
float m_fSkewAngleX; float _fSkewAngleX;
float m_fSkewAngleY; float _fSkewAngleY;
float m_fDisplayOpacity; float _fDisplayOpacity;
float m_fRealOpacity; float _fRealOpacity;
float m_fPivotX; float _fPivotX;
float m_fPivotY; float _fPivotY;
int m_nOrder; int _nOrder;
bool m_bVisiable; bool _bVisiable;
bool m_bAutoUpdate; bool _bAutoUpdate;
bool m_bSortChildrenNeeded; bool _bSortChildrenNeeded;
bool m_bTransformNeeded; bool _bTransformNeeded;
bool m_bPositionFixed; bool _bPositionFixed;
Collider * m_pCollider; Collider * _pCollider;
Scene * m_pParentScene; Scene * _pParentScene;
Node * m_pParent; Node * _pParent;
D2D1::Matrix3x2F m_MatriInitial; D2D1::Matrix3x2F _MatriInitial;
D2D1::Matrix3x2F m_MatriFinal; D2D1::Matrix3x2F _MatriFinal;
std::set<unsigned int> m_vColliders; std::set<unsigned int> _vColliders;
std::vector<Node*> m_vChildren; std::vector<Node*> _vChildren;
}; };
@ -551,7 +551,7 @@ public:
virtual void destroy() override; virtual void destroy() override;
protected: protected:
Image * m_pImage; Image * _pImage;
}; };
@ -735,10 +735,10 @@ protected:
void _createLayout(); void _createLayout();
protected: protected:
String m_sText; String _sText;
TextStyle m_TextStyle; TextStyle _TextStyle;
IDWriteTextFormat * m_pDWriteTextFormat; IDWriteTextFormat * _pDWriteTextFormat;
IDWriteTextLayout * m_pDWriteTextLayout; IDWriteTextLayout * _pDWriteTextLayout;
}; };
@ -829,14 +829,14 @@ protected:
virtual void _runCallback(); virtual void _runCallback();
protected: protected:
Node * m_pNormal; Node * _pNormal;
Node * m_pMouseover; Node * _pMouseover;
Node * m_pSelected; Node * _pSelected;
Node * m_pDisabled; Node * _pDisabled;
bool m_bEnable; bool _bEnable;
bool m_bIsSelected; bool _bIsSelected;
ButtonState m_eBtnState; ButtonState _eBtnState;
Function m_Callback; Function _Callback;
}; };
@ -943,15 +943,15 @@ protected:
virtual void _runCallback() override; virtual void _runCallback() override;
protected: protected:
Node * m_pNormalOn; Node * _pNormalOn;
Node * m_pNormalOff; Node * _pNormalOff;
Node * m_pMouseoverOn; Node * _pMouseoverOn;
Node * m_pMouseoverOff; Node * _pMouseoverOff;
Node * m_pSelectedOn; Node * _pSelectedOn;
Node * m_pSelectedOff; Node * _pSelectedOff;
Node * m_pDisabledOn; Node * _pDisabledOn;
Node * m_pDisabledOff; Node * _pDisabledOff;
bool m_bState; bool _bState;
}; };
@ -998,8 +998,8 @@ public:
); );
protected: protected:
bool m_bEnable; bool _bEnable;
std::vector<Button*> m_vButtons; std::vector<Button*> _vButtons;
}; };
} }

View File

@ -55,10 +55,10 @@ protected:
virtual void _renderFill() = 0; virtual void _renderFill() = 0;
protected: protected:
ShapeStyle m_nStyle; ShapeStyle _nStyle;
float m_fStrokeWidth; float _fStrokeWidth;
Color m_nLineColor; Color _nLineColor;
Color m_nFillColor; Color _nFillColor;
}; };
@ -163,8 +163,8 @@ protected:
virtual void _renderFill() override; virtual void _renderFill() override;
protected: protected:
float m_fRadiusX; float _fRadiusX;
float m_fRadiusY; float _fRadiusY;
}; };
@ -208,7 +208,7 @@ protected:
virtual void _renderFill() override; virtual void _renderFill() override;
protected: protected:
float m_fRadius; float _fRadius;
}; };
@ -263,8 +263,8 @@ protected:
virtual void _renderFill() override; virtual void _renderFill() override;
protected: protected:
float m_fRadiusX; float _fRadiusX;
float m_fRadiusY; float _fRadiusY;
}; };
} }

View File

@ -79,17 +79,17 @@ protected:
virtual void _stop(); virtual void _stop();
protected: protected:
bool m_bEnd; bool _bEnd;
double m_fLast; double _fLast;
double m_fDuration; double _fDuration;
double m_fRateOfProgress; double _fRateOfProgress;
Size m_WindowSize; Size _WindowSize;
Scene * m_pPrevScene; Scene * _pPrevScene;
Scene * m_pNextScene; Scene * _pNextScene;
ID2D1Layer * m_pPrevLayer; ID2D1Layer * _pPrevLayer;
ID2D1Layer * m_pNextLayer; ID2D1Layer * _pNextLayer;
D2D1_LAYER_PARAMETERS m_sPrevLayerParam; D2D1_LAYER_PARAMETERS _sPrevLayerParam;
D2D1_LAYER_PARAMETERS m_sNextLayerParam; D2D1_LAYER_PARAMETERS _sNextLayerParam;
}; };
@ -120,9 +120,9 @@ protected:
virtual void _reset() override; virtual void _reset() override;
protected: protected:
double m_fFadeOutDuration; double _fFadeOutDuration;
double m_fFadeInDuration; double _fFadeInDuration;
bool m_bFadeOutTransioning; bool _bFadeOutTransioning;
}; };
@ -170,9 +170,9 @@ protected:
virtual void _reset() override; virtual void _reset() override;
protected: protected:
Direct m_Direct; Direct _Direct;
Vector m_Vector; Vector _Vector;
Point m_NextPos; Point _NextPos;
}; };
} }