Timer and TimeManager have a new interface.
This commit is contained in:
parent
556f8f76de
commit
fdf903269b
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EAction::EAction()
|
||||
e2d::Action::Action()
|
||||
: m_bRunning(false)
|
||||
, m_bEnding(false)
|
||||
, m_bInit(false)
|
||||
|
|
@ -10,62 +10,62 @@ e2d::EAction::EAction()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::EAction::~EAction()
|
||||
e2d::Action::~Action()
|
||||
{
|
||||
}
|
||||
|
||||
bool e2d::EAction::isRunning()
|
||||
bool e2d::Action::isRunning()
|
||||
{
|
||||
return m_bRunning;
|
||||
}
|
||||
|
||||
bool e2d::EAction::_isEnding()
|
||||
bool e2d::Action::_isEnding()
|
||||
{
|
||||
return m_bEnding;
|
||||
}
|
||||
|
||||
void e2d::EAction::startWith(ENode* pTarget)
|
||||
void e2d::Action::startWith(Node* pTarget)
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_pTarget = pTarget;
|
||||
this->reset();
|
||||
}
|
||||
|
||||
void e2d::EAction::resume()
|
||||
void e2d::Action::resume()
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::EAction::pause()
|
||||
void e2d::Action::pause()
|
||||
{
|
||||
m_bRunning = false;
|
||||
}
|
||||
|
||||
void e2d::EAction::stop()
|
||||
void e2d::Action::stop()
|
||||
{
|
||||
m_bEnding = true;
|
||||
}
|
||||
|
||||
e2d::EAction * e2d::EAction::reverse() const
|
||||
e2d::Action * e2d::Action::reverse() const
|
||||
{
|
||||
ASSERT(false, "EAction cannot be reversed!");
|
||||
ASSERT(false, "Action cannot be reversed!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::EAction::getTarget()
|
||||
e2d::Node * e2d::Action::getTarget()
|
||||
{
|
||||
return m_pTarget;
|
||||
}
|
||||
|
||||
void e2d::EAction::_init()
|
||||
void e2d::Action::_init()
|
||||
{
|
||||
m_bInit = true;
|
||||
// 记录当前时间
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::EAction::_update()
|
||||
void e2d::Action::_update()
|
||||
{
|
||||
if (!m_bInit)
|
||||
{
|
||||
|
|
@ -73,14 +73,14 @@ void e2d::EAction::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EAction::reset()
|
||||
void e2d::Action::reset()
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bEnding = false;
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::EAction::_resetTime()
|
||||
void e2d::Action::_resetTime()
|
||||
{
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionCallback::EActionCallback(const std::function<void()>& callback) :
|
||||
e2d::ActionCallback::ActionCallback(const VoidFunction& callback) :
|
||||
m_Callback(callback)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EActionCallback * e2d::EActionCallback::clone() const
|
||||
e2d::ActionCallback * e2d::ActionCallback::clone() const
|
||||
{
|
||||
return new EActionCallback(m_Callback);
|
||||
return new ActionCallback(m_Callback);
|
||||
}
|
||||
|
||||
void e2d::EActionCallback::_init()
|
||||
void e2d::ActionCallback::_init()
|
||||
{
|
||||
// 执行回调函数的动作不需要初始化
|
||||
}
|
||||
|
||||
void e2d::EActionCallback::_update()
|
||||
void e2d::ActionCallback::_update()
|
||||
{
|
||||
m_Callback();
|
||||
this->stop();
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionDelay::EActionDelay(float duration)
|
||||
e2d::ActionDelay::ActionDelay(float duration)
|
||||
{
|
||||
m_fDelayTime = max(duration, 0);
|
||||
}
|
||||
|
||||
e2d::EActionDelay * e2d::EActionDelay::clone() const
|
||||
e2d::ActionDelay * e2d::ActionDelay::clone() const
|
||||
{
|
||||
return new EActionDelay(m_fDelayTime);
|
||||
return new ActionDelay(m_fDelayTime);
|
||||
}
|
||||
|
||||
void e2d::EActionDelay::_init()
|
||||
void e2d::ActionDelay::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
}
|
||||
|
||||
void e2d::EActionDelay::_update()
|
||||
void e2d::ActionDelay::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
// 判断时间间隔是否足够
|
||||
if ((ETime::getTotalTime() - m_fLast) >= m_fDelayTime)
|
||||
if ((Time::getTotalTime() - m_fLast) >= m_fDelayTime)
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionGradual::EActionGradual(float duration)
|
||||
e2d::ActionGradual::ActionGradual(float duration)
|
||||
: m_fRateOfProgress(0)
|
||||
{
|
||||
m_fDuration = max(duration, 0);
|
||||
}
|
||||
|
||||
void e2d::EActionGradual::_init()
|
||||
void e2d::ActionGradual::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
}
|
||||
|
||||
void e2d::EActionGradual::_update()
|
||||
void e2d::ActionGradual::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
// 判断时间间隔是否足够
|
||||
if (m_fDuration == 0)
|
||||
{
|
||||
|
|
@ -22,7 +22,7 @@ void e2d::EActionGradual::_update()
|
|||
return;
|
||||
}
|
||||
// 计算动画进度
|
||||
m_fRateOfProgress = min((ETime::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
// 判断动作是否结束
|
||||
if (m_fRateOfProgress >= 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionLoop::EActionLoop(EAction * action, int times /* = -1 */)
|
||||
e2d::ActionLoop::ActionLoop(Action * action, int times /* = -1 */)
|
||||
: m_pAction(action)
|
||||
, m_nTimes(0)
|
||||
, m_nTotalTimes(times)
|
||||
{
|
||||
ASSERT(m_pAction != nullptr, "EActionLoop NULL pointer exception!");
|
||||
ASSERT(m_pAction != nullptr, "ActionLoop NULL pointer exception!");
|
||||
m_pAction->retain();
|
||||
}
|
||||
|
||||
e2d::EActionLoop::~EActionLoop()
|
||||
e2d::ActionLoop::~ActionLoop()
|
||||
{
|
||||
SafeRelease(&m_pAction);
|
||||
}
|
||||
|
||||
e2d::EActionLoop * e2d::EActionLoop::clone() const
|
||||
e2d::ActionLoop * e2d::ActionLoop::clone() const
|
||||
{
|
||||
return new EActionLoop(m_pAction->clone());
|
||||
return new ActionLoop(m_pAction->clone());
|
||||
}
|
||||
|
||||
void e2d::EActionLoop::_init()
|
||||
void e2d::ActionLoop::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
m_pAction->m_pTarget = m_pTarget;
|
||||
m_pAction->_init();
|
||||
}
|
||||
|
||||
void e2d::EActionLoop::_update()
|
||||
void e2d::ActionLoop::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
|
||||
if (m_nTimes == m_nTotalTimes)
|
||||
{
|
||||
|
|
@ -42,20 +42,20 @@ void e2d::EActionLoop::_update()
|
|||
{
|
||||
m_nTimes++;
|
||||
|
||||
EAction::reset();
|
||||
Action::reset();
|
||||
m_pAction->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionLoop::reset()
|
||||
void e2d::ActionLoop::reset()
|
||||
{
|
||||
EAction::reset();
|
||||
Action::reset();
|
||||
|
||||
m_pAction->reset();
|
||||
m_nTimes = 0;
|
||||
}
|
||||
|
||||
void e2d::EActionLoop::_resetTime()
|
||||
void e2d::ActionLoop::_resetTime()
|
||||
{
|
||||
m_pAction->_resetTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionMoveBy::EActionMoveBy(float duration, EVector2 vector) :
|
||||
EActionGradual(duration)
|
||||
e2d::ActionMoveBy::ActionMoveBy(float duration, Vector vector) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_MoveVec = vector;
|
||||
}
|
||||
|
||||
void e2d::EActionMoveBy::_init()
|
||||
void e2d::ActionMoveBy::_init()
|
||||
{
|
||||
EActionGradual::_init();
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
{
|
||||
m_BeginPos = m_pTarget->getPos();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionMoveBy::_update()
|
||||
void e2d::ActionMoveBy::_update()
|
||||
{
|
||||
EActionGradual::_update();
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
{
|
||||
|
|
@ -33,12 +33,12 @@ void e2d::EActionMoveBy::_update()
|
|||
);
|
||||
}
|
||||
|
||||
e2d::EActionMoveBy * e2d::EActionMoveBy::clone() const
|
||||
e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const
|
||||
{
|
||||
return new EActionMoveBy(m_fDuration, m_MoveVec);
|
||||
return new ActionMoveBy(m_fDuration, m_MoveVec);
|
||||
}
|
||||
|
||||
e2d::EActionMoveBy * e2d::EActionMoveBy::reverse() const
|
||||
e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const
|
||||
{
|
||||
return new EActionMoveBy(m_fDuration, EVector2(-m_MoveVec.x, -m_MoveVec.y));
|
||||
return new ActionMoveBy(m_fDuration, Vector(-m_MoveVec.x, -m_MoveVec.y));
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionMoveTo::EActionMoveTo(float duration, EPoint pos) :
|
||||
EActionMoveBy(duration, EVector2())
|
||||
e2d::ActionMoveTo::ActionMoveTo(float duration, Point pos) :
|
||||
ActionMoveBy(duration, Vector())
|
||||
{
|
||||
m_EndPos = pos;
|
||||
}
|
||||
|
||||
e2d::EActionMoveTo * e2d::EActionMoveTo::clone() const
|
||||
e2d::ActionMoveTo * e2d::ActionMoveTo::clone() const
|
||||
{
|
||||
return new EActionMoveTo(m_fDuration, m_EndPos);
|
||||
return new ActionMoveTo(m_fDuration, m_EndPos);
|
||||
}
|
||||
|
||||
void e2d::EActionMoveTo::_init()
|
||||
void e2d::ActionMoveTo::_init()
|
||||
{
|
||||
EActionMoveBy::_init();
|
||||
ActionMoveBy::_init();
|
||||
m_MoveVec = m_EndPos - m_BeginPos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionOpacityBy::EActionOpacityBy(float duration, float opacity) :
|
||||
EActionGradual(duration)
|
||||
e2d::ActionOpacityBy::ActionOpacityBy(float duration, float opacity) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_nVariation = opacity;
|
||||
}
|
||||
|
||||
void e2d::EActionOpacityBy::_init()
|
||||
void e2d::ActionOpacityBy::_init()
|
||||
{
|
||||
EActionGradual::_init();
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
{
|
||||
m_nBeginVal = m_pTarget->getOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionOpacityBy::_update()
|
||||
void e2d::ActionOpacityBy::_update()
|
||||
{
|
||||
EActionGradual::_update();
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
{
|
||||
|
|
@ -29,12 +29,12 @@ void e2d::EActionOpacityBy::_update()
|
|||
m_pTarget->setOpacity(m_nBeginVal + m_nVariation * m_fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::EActionOpacityBy * e2d::EActionOpacityBy::clone() const
|
||||
e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const
|
||||
{
|
||||
return new EActionOpacityBy(m_fDuration, m_nVariation);
|
||||
return new ActionOpacityBy(m_fDuration, m_nVariation);
|
||||
}
|
||||
|
||||
e2d::EActionOpacityBy * e2d::EActionOpacityBy::reverse() const
|
||||
e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const
|
||||
{
|
||||
return new EActionOpacityBy(m_fDuration, -m_nVariation);
|
||||
return new ActionOpacityBy(m_fDuration, -m_nVariation);
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionOpacityTo::EActionOpacityTo(float duration, float opacity) :
|
||||
EActionOpacityBy(duration, 0)
|
||||
e2d::ActionOpacityTo::ActionOpacityTo(float duration, float opacity) :
|
||||
ActionOpacityBy(duration, 0)
|
||||
{
|
||||
m_nEndVal = opacity;
|
||||
}
|
||||
|
||||
e2d::EActionOpacityTo * e2d::EActionOpacityTo::clone() const
|
||||
e2d::ActionOpacityTo * e2d::ActionOpacityTo::clone() const
|
||||
{
|
||||
return new EActionOpacityTo(m_fDuration, m_nEndVal);
|
||||
return new ActionOpacityTo(m_fDuration, m_nEndVal);
|
||||
}
|
||||
|
||||
void e2d::EActionOpacityTo::_init()
|
||||
void e2d::ActionOpacityTo::_init()
|
||||
{
|
||||
EActionOpacityBy::_init();
|
||||
ActionOpacityBy::_init();
|
||||
m_nVariation = m_nEndVal - m_nBeginVal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionRotateBy::EActionRotateBy(float duration, float rotation) :
|
||||
EActionGradual(duration)
|
||||
e2d::ActionRotateBy::ActionRotateBy(float duration, float rotation) :
|
||||
ActionGradual(duration)
|
||||
{
|
||||
m_nVariation = rotation;
|
||||
}
|
||||
|
||||
void e2d::EActionRotateBy::_init()
|
||||
void e2d::ActionRotateBy::_init()
|
||||
{
|
||||
EActionGradual::_init();
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
{
|
||||
m_nBeginVal = m_pTarget->getRotation();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionRotateBy::_update()
|
||||
void e2d::ActionRotateBy::_update()
|
||||
{
|
||||
EActionGradual::_update();
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
{
|
||||
|
|
@ -30,12 +30,12 @@ void e2d::EActionRotateBy::_update()
|
|||
m_pTarget->setRotation(m_nBeginVal + m_nVariation * m_fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::EActionRotateBy * e2d::EActionRotateBy::clone() const
|
||||
e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const
|
||||
{
|
||||
return new EActionRotateBy(m_fDuration, m_nVariation);
|
||||
return new ActionRotateBy(m_fDuration, m_nVariation);
|
||||
}
|
||||
|
||||
e2d::EActionRotateBy * e2d::EActionRotateBy::reverse() const
|
||||
e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const
|
||||
{
|
||||
return new EActionRotateBy(m_fDuration, -m_nVariation);
|
||||
return new ActionRotateBy(m_fDuration, -m_nVariation);
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionRotateTo::EActionRotateTo(float duration, float rotation) :
|
||||
EActionRotateBy(duration, 0)
|
||||
e2d::ActionRotateTo::ActionRotateTo(float duration, float rotation) :
|
||||
ActionRotateBy(duration, 0)
|
||||
{
|
||||
m_nEndVal = rotation;
|
||||
}
|
||||
|
||||
e2d::EActionRotateTo * e2d::EActionRotateTo::clone() const
|
||||
e2d::ActionRotateTo * e2d::ActionRotateTo::clone() const
|
||||
{
|
||||
return new EActionRotateTo(m_fDuration, m_nEndVal);
|
||||
return new ActionRotateTo(m_fDuration, m_nEndVal);
|
||||
}
|
||||
|
||||
void e2d::EActionRotateTo::_init()
|
||||
void e2d::ActionRotateTo::_init()
|
||||
{
|
||||
EActionRotateBy::_init();
|
||||
ActionRotateBy::_init();
|
||||
m_nVariation = m_nEndVal - m_nBeginVal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
|
||||
e2d::EActionScaleBy::EActionScaleBy(float duration, float scale)
|
||||
: EActionGradual(duration)
|
||||
e2d::ActionScaleBy::ActionScaleBy(float duration, float scale)
|
||||
: ActionGradual(duration)
|
||||
{
|
||||
m_nVariationX = scale;
|
||||
m_nVariationY = scale;
|
||||
}
|
||||
|
||||
e2d::EActionScaleBy::EActionScaleBy(float duration, float scaleX, float scaleY)
|
||||
: EActionGradual(duration)
|
||||
e2d::ActionScaleBy::ActionScaleBy(float duration, float scaleX, float scaleY)
|
||||
: ActionGradual(duration)
|
||||
{
|
||||
m_nVariationX = scaleX;
|
||||
m_nVariationY = scaleY;
|
||||
}
|
||||
|
||||
void e2d::EActionScaleBy::_init()
|
||||
void e2d::ActionScaleBy::_init()
|
||||
{
|
||||
EActionGradual::_init();
|
||||
ActionGradual::_init();
|
||||
if (m_pTarget)
|
||||
{
|
||||
m_nBeginScaleX = m_pTarget->getScaleX();
|
||||
|
|
@ -25,9 +25,9 @@ void e2d::EActionScaleBy::_init()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionScaleBy::_update()
|
||||
void e2d::ActionScaleBy::_update()
|
||||
{
|
||||
EActionGradual::_update();
|
||||
ActionGradual::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
{
|
||||
|
|
@ -41,12 +41,12 @@ void e2d::EActionScaleBy::_update()
|
|||
m_nBeginScaleX + m_nVariationX * m_fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::EActionScaleBy * e2d::EActionScaleBy::clone() const
|
||||
e2d::ActionScaleBy * e2d::ActionScaleBy::clone() const
|
||||
{
|
||||
return new EActionScaleBy(m_fDuration, m_nVariationX, m_nVariationY);
|
||||
return new ActionScaleBy(m_fDuration, m_nVariationX, m_nVariationY);
|
||||
}
|
||||
|
||||
e2d::EActionScaleBy * e2d::EActionScaleBy::reverse() const
|
||||
e2d::ActionScaleBy * e2d::ActionScaleBy::reverse() const
|
||||
{
|
||||
return new EActionScaleBy(m_fDuration, -m_nVariationX, -m_nVariationY);
|
||||
return new ActionScaleBy(m_fDuration, -m_nVariationX, -m_nVariationY);
|
||||
}
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionScaleTo::EActionScaleTo(float duration, float scale)
|
||||
: EActionScaleBy(duration, 0, 0)
|
||||
e2d::ActionScaleTo::ActionScaleTo(float duration, float scale)
|
||||
: ActionScaleBy(duration, 0, 0)
|
||||
{
|
||||
m_nEndScaleX = scale;
|
||||
m_nEndScaleY = scale;
|
||||
}
|
||||
|
||||
e2d::EActionScaleTo::EActionScaleTo(float duration, float scaleX, float scaleY)
|
||||
: EActionScaleBy(duration, 0, 0)
|
||||
e2d::ActionScaleTo::ActionScaleTo(float duration, float scaleX, float scaleY)
|
||||
: ActionScaleBy(duration, 0, 0)
|
||||
{
|
||||
m_nEndScaleX = scaleX;
|
||||
m_nEndScaleY = scaleY;
|
||||
}
|
||||
|
||||
e2d::EActionScaleTo * e2d::EActionScaleTo::clone() const
|
||||
e2d::ActionScaleTo * e2d::ActionScaleTo::clone() const
|
||||
{
|
||||
return new EActionScaleTo(m_fDuration, m_nEndScaleX, m_nEndScaleY);
|
||||
return new ActionScaleTo(m_fDuration, m_nEndScaleX, m_nEndScaleY);
|
||||
}
|
||||
|
||||
void e2d::EActionScaleTo::_init()
|
||||
void e2d::ActionScaleTo::_init()
|
||||
{
|
||||
EActionScaleBy::_init();
|
||||
ActionScaleBy::_init();
|
||||
m_nVariationX = m_nEndScaleX - m_nBeginScaleX;
|
||||
m_nVariationY = m_nEndScaleY - m_nBeginScaleY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionSequence::EActionSequence() :
|
||||
e2d::ActionSequence::ActionSequence() :
|
||||
m_nActionIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EActionSequence::EActionSequence(int number, EAction * action1, ...) :
|
||||
e2d::ActionSequence::ActionSequence(int number, Action * action1, ...) :
|
||||
m_nActionIndex(0)
|
||||
{
|
||||
EAction ** ppAction = &action1;
|
||||
Action ** ppAction = &action1;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
ASSERT((*ppAction) != nullptr, "EActionSequence NULL pointer exception!");
|
||||
this->addAction(*ppAction);
|
||||
ASSERT((*ppAction) != nullptr, "ActionSequence NULL pointer exception!");
|
||||
this->_add(*ppAction);
|
||||
ppAction++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
|
||||
e2d::EActionSequence::~EActionSequence()
|
||||
e2d::ActionSequence::~ActionSequence()
|
||||
{
|
||||
for (auto action : m_vActions)
|
||||
{
|
||||
|
|
@ -27,9 +27,9 @@ e2d::EActionSequence::~EActionSequence()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionSequence::_init()
|
||||
void e2d::ActionSequence::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
// 将所有动作与目标绑定
|
||||
if (m_pTarget)
|
||||
{
|
||||
|
|
@ -42,9 +42,9 @@ void e2d::EActionSequence::_init()
|
|||
m_vActions[0]->_init();
|
||||
}
|
||||
|
||||
void e2d::EActionSequence::_update()
|
||||
void e2d::ActionSequence::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
|
||||
auto &action = m_vActions[m_nActionIndex];
|
||||
action->_update();
|
||||
|
|
@ -63,9 +63,9 @@ void e2d::EActionSequence::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionSequence::reset()
|
||||
void e2d::ActionSequence::reset()
|
||||
{
|
||||
EAction::reset();
|
||||
Action::reset();
|
||||
for (auto action : m_vActions)
|
||||
{
|
||||
action->reset();
|
||||
|
|
@ -73,7 +73,7 @@ void e2d::EActionSequence::reset()
|
|||
m_nActionIndex = 0;
|
||||
}
|
||||
|
||||
void e2d::EActionSequence::_resetTime()
|
||||
void e2d::ActionSequence::_resetTime()
|
||||
{
|
||||
for (auto action : m_vActions)
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ void e2d::EActionSequence::_resetTime()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionSequence::addAction(EAction * action)
|
||||
void e2d::ActionSequence::_add(Action * action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
|
|
@ -90,28 +90,28 @@ void e2d::EActionSequence::addAction(EAction * action)
|
|||
}
|
||||
}
|
||||
|
||||
e2d::EActionSequence * e2d::EActionSequence::clone() const
|
||||
e2d::ActionSequence * e2d::ActionSequence::clone() const
|
||||
{
|
||||
auto a = new EActionSequence();
|
||||
auto a = new ActionSequence();
|
||||
for (auto action : m_vActions)
|
||||
{
|
||||
a->addAction(action->clone());
|
||||
a->_add(action->clone());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
e2d::EActionSequence * e2d::EActionSequence::reverse(bool actionReverse) const
|
||||
e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const
|
||||
{
|
||||
auto a = new EActionSequence();
|
||||
auto a = new ActionSequence();
|
||||
for (auto action : m_vActions)
|
||||
{
|
||||
if (actionReverse)
|
||||
{
|
||||
a->addAction(action->reverse());
|
||||
a->_add(action->reverse());
|
||||
}
|
||||
else
|
||||
{
|
||||
a->addAction(action->clone());
|
||||
a->_add(action->clone());
|
||||
}
|
||||
}
|
||||
// 将动作顺序逆序排列
|
||||
|
|
|
|||
|
|
@ -1,78 +1,89 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionTwo::EActionTwo(EAction * actionFirst, EAction * actionSecond) :
|
||||
m_pFirstAction(actionFirst),
|
||||
m_pSecondAction(actionSecond)
|
||||
e2d::ActionTwo::ActionTwo(Action * pActionFirst, Action * pActionSecond, bool bAtSameTime/* = false*/)
|
||||
: m_pFirstAction(pActionFirst)
|
||||
, m_pSecondAction(pActionSecond)
|
||||
, m_bAtSameTime(bAtSameTime)
|
||||
{
|
||||
ASSERT(m_pFirstAction && m_pSecondAction, "EActionTwo NULL pointer exception!");
|
||||
ASSERT(m_pFirstAction && m_pSecondAction, "ActionTwo NULL pointer exception!");
|
||||
m_pFirstAction->retain();
|
||||
m_pSecondAction->retain();
|
||||
}
|
||||
|
||||
e2d::EActionTwo::~EActionTwo()
|
||||
e2d::ActionTwo::~ActionTwo()
|
||||
{
|
||||
SafeRelease(&m_pFirstAction);
|
||||
SafeRelease(&m_pSecondAction);
|
||||
}
|
||||
|
||||
e2d::EActionTwo * e2d::EActionTwo::clone() const
|
||||
e2d::ActionTwo * e2d::ActionTwo::clone() const
|
||||
{
|
||||
return new EActionTwo(m_pFirstAction->clone(), m_pSecondAction->clone());
|
||||
return new ActionTwo(m_pFirstAction->clone(), m_pSecondAction->clone());
|
||||
}
|
||||
|
||||
e2d::EActionTwo * e2d::EActionTwo::reverse(bool actionReverse) const
|
||||
e2d::ActionTwo * e2d::ActionTwo::reverse(bool actionReverse) const
|
||||
{
|
||||
if (actionReverse)
|
||||
{
|
||||
return new EActionTwo(m_pSecondAction->reverse(), m_pFirstAction->reverse());
|
||||
return new ActionTwo(m_pSecondAction->reverse(), m_pFirstAction->reverse());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new EActionTwo(m_pSecondAction->clone(), m_pFirstAction->clone());
|
||||
return new ActionTwo(m_pSecondAction->clone(), m_pFirstAction->clone());
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionTwo::_init()
|
||||
void e2d::ActionTwo::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
m_pFirstAction->m_pTarget = m_pTarget;
|
||||
m_pSecondAction->m_pTarget = m_pTarget;
|
||||
|
||||
m_pFirstAction->_init();
|
||||
if (m_bAtSameTime) m_pSecondAction->_init();
|
||||
}
|
||||
|
||||
void e2d::EActionTwo::_update()
|
||||
void e2d::ActionTwo::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
|
||||
if (!m_pFirstAction->_isEnding())
|
||||
{
|
||||
m_pFirstAction->_update();
|
||||
if (m_pFirstAction->_isEnding())
|
||||
|
||||
if (!m_bAtSameTime && m_pFirstAction->_isEnding())
|
||||
{
|
||||
// 返回 true 表示第一个动作已经结束
|
||||
m_pSecondAction->_init();
|
||||
}
|
||||
}
|
||||
else if (!m_pSecondAction->_isEnding())
|
||||
|
||||
if (m_bAtSameTime)
|
||||
{
|
||||
if (!m_pSecondAction->_isEnding())
|
||||
{
|
||||
m_pSecondAction->_update();
|
||||
}
|
||||
}
|
||||
else if (m_pFirstAction->_isEnding())
|
||||
{
|
||||
m_pSecondAction->_update();
|
||||
}
|
||||
else
|
||||
|
||||
if (m_pFirstAction->_isEnding() && m_pSecondAction->_isEnding())
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionTwo::reset()
|
||||
void e2d::ActionTwo::reset()
|
||||
{
|
||||
EAction::reset();
|
||||
Action::reset();
|
||||
|
||||
m_pFirstAction->reset();
|
||||
m_pSecondAction->reset();
|
||||
}
|
||||
|
||||
void e2d::EActionTwo::_resetTime()
|
||||
void e2d::ActionTwo::_resetTime()
|
||||
{
|
||||
m_pFirstAction->_resetTime();
|
||||
m_pSecondAction->_resetTime();
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EActionTwoAtSameTime::EActionTwoAtSameTime(EAction * actionFirst, EAction * actionSecond) :
|
||||
m_pFirstAction(actionFirst),
|
||||
m_pSecondAction(actionSecond)
|
||||
{
|
||||
ASSERT(m_pFirstAction && m_pSecondAction, "EActionTwoAtSameTime NULL pointer exception!");
|
||||
m_pFirstAction->retain();
|
||||
m_pSecondAction->retain();
|
||||
}
|
||||
|
||||
e2d::EActionTwoAtSameTime::~EActionTwoAtSameTime()
|
||||
{
|
||||
SafeRelease(&m_pFirstAction);
|
||||
SafeRelease(&m_pSecondAction);
|
||||
}
|
||||
|
||||
e2d::EActionTwoAtSameTime * e2d::EActionTwoAtSameTime::clone() const
|
||||
{
|
||||
return new EActionTwoAtSameTime(m_pFirstAction->clone(), m_pSecondAction->clone());
|
||||
}
|
||||
|
||||
e2d::EActionTwoAtSameTime * e2d::EActionTwoAtSameTime::reverse(bool actionReverse) const
|
||||
{
|
||||
if (actionReverse)
|
||||
{
|
||||
return new EActionTwoAtSameTime(m_pSecondAction->reverse(), m_pFirstAction->reverse());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new EActionTwoAtSameTime(m_pSecondAction->clone(), m_pFirstAction->clone());
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionTwoAtSameTime::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
m_pFirstAction->m_pTarget = m_pTarget;
|
||||
m_pSecondAction->m_pTarget = m_pTarget;
|
||||
|
||||
m_pFirstAction->_init();
|
||||
m_pSecondAction->_init();
|
||||
}
|
||||
|
||||
void e2d::EActionTwoAtSameTime::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
|
||||
if (!m_pFirstAction->_isEnding())
|
||||
{
|
||||
m_pFirstAction->_update();
|
||||
}
|
||||
if (!m_pSecondAction->_isEnding())
|
||||
{
|
||||
m_pSecondAction->_update();
|
||||
}
|
||||
|
||||
// 两个动作都结束时,动作结束
|
||||
if (m_pFirstAction->_isEnding() &&
|
||||
m_pSecondAction->_isEnding())
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionTwoAtSameTime::reset()
|
||||
{
|
||||
EAction::reset();
|
||||
|
||||
m_pFirstAction->reset();
|
||||
m_pSecondAction->reset();
|
||||
}
|
||||
|
||||
void e2d::EActionTwoAtSameTime::_resetTime()
|
||||
{
|
||||
m_pFirstAction->_resetTime();
|
||||
m_pSecondAction->_resetTime();
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
#include "..\eactions.h"
|
||||
|
||||
e2d::EAnimation::EAnimation()
|
||||
e2d::Animation::Animation()
|
||||
: m_nFrameIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EAnimation::EAnimation(float invertal)
|
||||
e2d::Animation::Animation(float invertal)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(invertal)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EAnimation::~EAnimation()
|
||||
e2d::Animation::~Animation()
|
||||
{
|
||||
for (auto frame : m_vFrames)
|
||||
{
|
||||
|
|
@ -19,19 +19,19 @@ e2d::EAnimation::~EAnimation()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EAnimation::setInterval(float interval)
|
||||
void e2d::Animation::setInterval(float interval)
|
||||
{
|
||||
m_fInterval = max(interval, 0);
|
||||
}
|
||||
|
||||
void e2d::EAnimation::_init()
|
||||
void e2d::Animation::_init()
|
||||
{
|
||||
EAction::_init();
|
||||
Action::_init();
|
||||
}
|
||||
|
||||
void e2d::EAnimation::_update()
|
||||
void e2d::Animation::_update()
|
||||
{
|
||||
EAction::_update();
|
||||
Action::_update();
|
||||
|
||||
if (m_pTarget == nullptr)
|
||||
{
|
||||
|
|
@ -40,12 +40,12 @@ void e2d::EAnimation::_update()
|
|||
}
|
||||
|
||||
// 判断时间间隔是否足够
|
||||
while ((ETime::getTotalTime() - m_fLast) >= m_fInterval)
|
||||
while ((Time::getTotalTime() - m_fLast) >= m_fInterval)
|
||||
{
|
||||
// 重新记录时间
|
||||
m_fLast += m_fInterval;
|
||||
// 加载关键帧
|
||||
static_cast<ESprite*>(m_pTarget)->loadFrom(m_vFrames[m_nFrameIndex]);
|
||||
static_cast<Sprite*>(m_pTarget)->loadFrom(m_vFrames[m_nFrameIndex]);
|
||||
m_nFrameIndex++;
|
||||
// 判断动作是否结束
|
||||
if (m_nFrameIndex == m_vFrames.size())
|
||||
|
|
@ -56,13 +56,13 @@ void e2d::EAnimation::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EAnimation::reset()
|
||||
void e2d::Animation::reset()
|
||||
{
|
||||
EAction::reset();
|
||||
Action::reset();
|
||||
m_nFrameIndex = 0;
|
||||
}
|
||||
|
||||
void e2d::EAnimation::addKeyframe(EImage * frame)
|
||||
void e2d::Animation::addKeyframe(Image * frame)
|
||||
{
|
||||
if (frame)
|
||||
{
|
||||
|
|
@ -71,9 +71,9 @@ void e2d::EAnimation::addKeyframe(EImage * frame)
|
|||
}
|
||||
}
|
||||
|
||||
e2d::EAnimation * e2d::EAnimation::clone() const
|
||||
e2d::Animation * e2d::Animation::clone() const
|
||||
{
|
||||
auto a = new EAnimation(m_fInterval);
|
||||
auto a = new Animation(m_fInterval);
|
||||
for (auto frame : m_vFrames)
|
||||
{
|
||||
a->addKeyframe(frame);
|
||||
|
|
@ -81,7 +81,7 @@ e2d::EAnimation * e2d::EAnimation::clone() const
|
|||
return a;
|
||||
}
|
||||
|
||||
e2d::EAnimation * e2d::EAnimation::reverse() const
|
||||
e2d::Animation * e2d::Animation::reverse() const
|
||||
{
|
||||
auto a = this->clone();
|
||||
a->m_vFrames.reserve(m_vFrames.size());
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ static bool s_bPaused = false;
|
|||
// 是否进行过初始化
|
||||
static bool s_bInitialized = false;
|
||||
// AppName
|
||||
static e2d::EString s_sAppName;
|
||||
static e2d::String s_sAppName;
|
||||
|
||||
|
||||
bool e2d::EGame::init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, LPCTSTR sAppname)
|
||||
bool e2d::Game::init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, LPCTSTR sAppname)
|
||||
{
|
||||
if (s_bInitialized)
|
||||
{
|
||||
|
|
@ -26,44 +26,44 @@ bool e2d::EGame::init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIc
|
|||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
|
||||
// 创建设备无关资源
|
||||
if (!ERenderer::__createDeviceIndependentResources())
|
||||
if (!Renderer::__createDeviceIndependentResources())
|
||||
{
|
||||
WARN_IF(true, "ERenderer::__createDeviceIndependentResources Failed!");
|
||||
WARN_IF(true, "Renderer::__createDeviceIndependentResources Failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
// 初始化窗口
|
||||
if (!EWindow::__init(sTitle, nWidth, nHeight, pIconID))
|
||||
if (!Window::__init(sTitle, nWidth, nHeight, pIconID))
|
||||
{
|
||||
WARN_IF(true, "EWindow::__init Failed!");
|
||||
WARN_IF(true, "Window::__init Failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
// 创建设备相关资源
|
||||
if (!ERenderer::__createDeviceResources())
|
||||
if (!Renderer::__createDeviceResources())
|
||||
{
|
||||
WARN_IF(true, "ERenderer::__createDeviceResources Failed!");
|
||||
WARN_IF(true, "Renderer::__createDeviceResources Failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
// 初始化 DirectInput
|
||||
if (!EInput::__init())
|
||||
if (!Input::__init())
|
||||
{
|
||||
WARN_IF(true, "EInput::__init Failed!");
|
||||
WARN_IF(true, "Input::__init Failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
// 初始化播放器
|
||||
if (!EMusicManager::__init())
|
||||
if (!MusicManager::__init())
|
||||
{
|
||||
WARN_IF(true, "EMusicManager::__init Failed!");
|
||||
WARN_IF(true, "MusicManager::__init Failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
// 重设 Client 大小
|
||||
EWindow::setSize(nWidth, nHeight);
|
||||
Window::setSize(nWidth, nHeight);
|
||||
// 设置 AppName
|
||||
s_sAppName = (sAppname != nullptr) ? sAppname : EWindow::getTitle();
|
||||
s_sAppName = (sAppname != nullptr) ? sAppname : Window::getTitle();
|
||||
// 标志初始化成功
|
||||
s_bInitialized = true;
|
||||
|
||||
|
|
@ -72,113 +72,109 @@ bool e2d::EGame::init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIc
|
|||
return s_bInitialized;
|
||||
}
|
||||
|
||||
int e2d::EGame::run()
|
||||
int e2d::Game::run()
|
||||
{
|
||||
if (!s_bInitialized)
|
||||
{
|
||||
ASSERT(false, "You must initialize EGame first!");
|
||||
ASSERT(false, "You must initialize Game first!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 初始化场景管理器
|
||||
ESceneManager::__init();
|
||||
SceneManager::__init();
|
||||
// 显示窗口
|
||||
::ShowWindow(EWindow::getHWnd(), SW_SHOWNORMAL);
|
||||
::ShowWindow(Window::getHWnd(), SW_SHOWNORMAL);
|
||||
// 刷新窗口内容
|
||||
::UpdateWindow(EWindow::getHWnd());
|
||||
::UpdateWindow(Window::getHWnd());
|
||||
// 处理窗口消息
|
||||
EWindow::__poll();
|
||||
Window::__poll();
|
||||
// 初始化计时
|
||||
ETime::__init();
|
||||
Time::__init();
|
||||
|
||||
while (!s_bEndGame)
|
||||
{
|
||||
// 处理窗口消息
|
||||
EWindow::__poll();
|
||||
Window::__poll();
|
||||
// 刷新时间
|
||||
ETime::__updateNow();
|
||||
Time::__updateNow();
|
||||
|
||||
// 判断是否达到了刷新状态
|
||||
if (ETime::__isReady())
|
||||
if (Time::__isReady())
|
||||
{
|
||||
while (ETime::__isReady())
|
||||
while (Time::__isReady())
|
||||
{
|
||||
EInput::__updateDeviceState(); // 获取用户输入
|
||||
ESceneManager::__update(); // 更新场景内容
|
||||
ETime::__updateLast(); // 刷新时间信息
|
||||
Input::__updateDeviceState(); // 获取用户输入
|
||||
SceneManager::__update(); // 更新场景内容
|
||||
Time::__updateLast(); // 刷新时间信息
|
||||
}
|
||||
|
||||
if (!s_bPaused)
|
||||
{
|
||||
ETimerManager::__update(); // 定时器管理器执行程序
|
||||
EActionManager::__update(); // 动作管理器执行程序
|
||||
}
|
||||
|
||||
ERenderer::__render(); // 渲染游戏画面
|
||||
TimerManager::__update(); // 定时器管理器执行程序
|
||||
ActionManager::__update(); // 动作管理器执行程序
|
||||
Renderer::__render(); // 渲染游戏画面
|
||||
}
|
||||
else
|
||||
{
|
||||
EObjectManager::__flush(); // 刷新内存池
|
||||
ETime::__sleep(); // 挂起线程
|
||||
ObjectManager::__flush(); // 刷新内存池
|
||||
Time::__sleep(); // 挂起线程
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void e2d::EGame::pause()
|
||||
void e2d::Game::pause()
|
||||
{
|
||||
s_bPaused = true;
|
||||
}
|
||||
|
||||
void e2d::EGame::resume()
|
||||
void e2d::Game::resume()
|
||||
{
|
||||
if (isPaused())
|
||||
{
|
||||
s_bPaused = false;
|
||||
// 刷新当前时间
|
||||
ETime::__updateLast();
|
||||
Time::__updateLast();
|
||||
// 重置动画和定时器
|
||||
EActionManager::__resetAllActions();
|
||||
ETimerManager::__resetAllTimers();
|
||||
ActionManager::__resetAllActions();
|
||||
TimerManager::__resetAllTimers();
|
||||
}
|
||||
}
|
||||
|
||||
bool e2d::EGame::isPaused()
|
||||
bool e2d::Game::isPaused()
|
||||
{
|
||||
return s_bPaused;
|
||||
}
|
||||
|
||||
void e2d::EGame::quit()
|
||||
void e2d::Game::quit()
|
||||
{
|
||||
s_bEndGame = true; // 这个变量将控制游戏是否结束
|
||||
}
|
||||
|
||||
void e2d::EGame::uninit()
|
||||
void e2d::Game::uninit()
|
||||
{
|
||||
// 删除所有场景
|
||||
ESceneManager::__uninit();
|
||||
SceneManager::__uninit();
|
||||
// 关闭输入
|
||||
EInput::__uninit();
|
||||
Input::__uninit();
|
||||
// 关闭播放器
|
||||
EMusicManager::__uninit();
|
||||
MusicManager::__uninit();
|
||||
// 恢复计时操作
|
||||
ETime::__uninit();
|
||||
Time::__uninit();
|
||||
// 清空图片缓存
|
||||
EImage::clearCache();
|
||||
Image::clearCache();
|
||||
// 刷新内存池
|
||||
EObjectManager::__flush();
|
||||
ObjectManager::__flush();
|
||||
// 删除渲染相关资源
|
||||
ERenderer::__discardResources();
|
||||
Renderer::__discardResources();
|
||||
// 销毁窗口
|
||||
EWindow::__uninit();
|
||||
Window::__uninit();
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
s_bInitialized = false;
|
||||
}
|
||||
|
||||
e2d::EString e2d::EGame::getAppName()
|
||||
e2d::String e2d::Game::getAppName()
|
||||
{
|
||||
return s_sAppName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ static DIMOUSESTATE s_MouseRecordState; //
|
|||
static POINT s_MousePosition; // Êó±êλÖô洢½á¹¹Ìå
|
||||
|
||||
|
||||
void EInput::__uninit()
|
||||
void Input::__uninit()
|
||||
{
|
||||
if (s_KeyboardDevice)
|
||||
s_KeyboardDevice->Unacquire();
|
||||
|
|
@ -28,7 +28,7 @@ void EInput::__uninit()
|
|||
SafeReleaseInterface(&s_pDirectInput);
|
||||
}
|
||||
|
||||
bool EInput::__init()
|
||||
bool Input::__init()
|
||||
{
|
||||
ZeroMemory(s_KeyBuffer, sizeof(s_KeyBuffer));
|
||||
ZeroMemory(s_KeyRecordBuffer, sizeof(s_KeyRecordBuffer));
|
||||
|
|
@ -56,7 +56,7 @@ bool EInput::__init()
|
|||
if (SUCCEEDED(hr))
|
||||
{
|
||||
s_KeyboardDevice->SetCooperativeLevel(
|
||||
EWindow::getHWnd(),
|
||||
Window::getHWnd(),
|
||||
DISCL_FOREGROUND | DISCL_NONEXCLUSIVE
|
||||
);
|
||||
s_KeyboardDevice->SetDataFormat(
|
||||
|
|
@ -69,7 +69,7 @@ bool EInput::__init()
|
|||
MessageBox(nullptr, L"Keyboard not found. The game will now exit.",
|
||||
L"Error",
|
||||
MB_ICONERROR | MB_OK);
|
||||
EGame::quit();
|
||||
Game::quit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ bool EInput::__init()
|
|||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
s_MouseDevice->SetCooperativeLevel(EWindow::getHWnd(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
s_MouseDevice->SetCooperativeLevel(Window::getHWnd(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
s_MouseDevice->SetDataFormat(&c_dfDIMouse);
|
||||
s_MouseDevice->Acquire();
|
||||
s_MouseDevice->Poll();
|
||||
|
|
@ -91,7 +91,7 @@ bool EInput::__init()
|
|||
MessageBox(nullptr, L"Mouse not found. The game will now exit.",
|
||||
L"Error",
|
||||
MB_ICONERROR | MB_OK);
|
||||
EGame::quit();
|
||||
Game::quit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ bool EInput::__init()
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void EInput::__updateDeviceState()
|
||||
void Input::__updateDeviceState()
|
||||
{
|
||||
if (s_KeyboardDevice)
|
||||
{
|
||||
|
|
@ -137,119 +137,119 @@ void EInput::__updateDeviceState()
|
|||
}
|
||||
|
||||
GetCursorPos(&s_MousePosition);
|
||||
ScreenToClient(EWindow::getHWnd(), &s_MousePosition);
|
||||
ScreenToClient(Window::getHWnd(), &s_MousePosition);
|
||||
}
|
||||
|
||||
bool EInput::isKeyDown(int nKeyCode)
|
||||
bool Input::isKeyDown(int nKeyCode)
|
||||
{
|
||||
if (s_KeyBuffer[nKeyCode] & 0x80)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isKeyPress(int nKeyCode)
|
||||
bool Input::isKeyPress(int nKeyCode)
|
||||
{
|
||||
if ((s_KeyBuffer[nKeyCode] & 0x80) && !(s_KeyRecordBuffer[nKeyCode] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isKeyRelease(int nKeyCode)
|
||||
bool Input::isKeyRelease(int nKeyCode)
|
||||
{
|
||||
if (!(s_KeyBuffer[nKeyCode] & 0x80) && (s_KeyRecordBuffer[nKeyCode] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseLButtonDown()
|
||||
bool Input::isMouseLButtonDown()
|
||||
{
|
||||
if (s_MouseState.rgbButtons[0] & 0x80)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseRButtonDown()
|
||||
bool Input::isMouseRButtonDown()
|
||||
{
|
||||
if (s_MouseState.rgbButtons[1] & 0x80)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseMButtonDown()
|
||||
bool Input::isMouseMButtonDown()
|
||||
{
|
||||
if (s_MouseState.rgbButtons[2] & 0x80)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseLButtonPress()
|
||||
bool Input::isMouseLButtonPress()
|
||||
{
|
||||
if ((s_MouseState.rgbButtons[0] & 0x80) && !(s_MouseRecordState.rgbButtons[0] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseRButtonPress()
|
||||
bool Input::isMouseRButtonPress()
|
||||
{
|
||||
if ((s_MouseState.rgbButtons[1] & 0x80) && !(s_MouseRecordState.rgbButtons[1] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseMButtonPress()
|
||||
bool Input::isMouseMButtonPress()
|
||||
{
|
||||
if ((s_MouseState.rgbButtons[2] & 0x80) && !(s_MouseRecordState.rgbButtons[2] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseLButtonRelease()
|
||||
bool Input::isMouseLButtonRelease()
|
||||
{
|
||||
if (!(s_MouseState.rgbButtons[0] & 0x80) && (s_MouseRecordState.rgbButtons[0] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseRButtonRelease()
|
||||
bool Input::isMouseRButtonRelease()
|
||||
{
|
||||
if (!(s_MouseState.rgbButtons[1] & 0x80) && (s_MouseRecordState.rgbButtons[1] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EInput::isMouseMButtonRelease()
|
||||
bool Input::isMouseMButtonRelease()
|
||||
{
|
||||
if (!(s_MouseState.rgbButtons[2] & 0x80) && (s_MouseRecordState.rgbButtons[2] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
float EInput::getMouseX()
|
||||
float Input::getMouseX()
|
||||
{
|
||||
return (float)s_MousePosition.x;
|
||||
}
|
||||
|
||||
float EInput::getMouseY()
|
||||
float Input::getMouseY()
|
||||
{
|
||||
return (float)s_MousePosition.y;
|
||||
}
|
||||
|
||||
EPoint EInput::getMousePos()
|
||||
Point Input::getMousePos()
|
||||
{
|
||||
return EPoint((float)s_MousePosition.x, (float)s_MousePosition.y);
|
||||
return Point((float)s_MousePosition.x, (float)s_MousePosition.y);
|
||||
}
|
||||
|
||||
float EInput::getMouseDeltaX()
|
||||
float Input::getMouseDeltaX()
|
||||
{
|
||||
return (float)s_MouseState.lX;
|
||||
}
|
||||
|
||||
float EInput::getMouseDeltaY()
|
||||
float Input::getMouseDeltaY()
|
||||
{
|
||||
return (float)s_MouseState.lY;
|
||||
}
|
||||
|
||||
float EInput::getMouseDeltaZ()
|
||||
float Input::getMouseDeltaZ()
|
||||
{
|
||||
return (float)s_MouseState.lZ;
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ static IDWriteFactory * s_pDWriteFactory = nullptr;
|
|||
static D2D1_COLOR_F s_nClearColor = D2D1::ColorF(D2D1::ColorF::Black);
|
||||
|
||||
|
||||
bool e2d::ERenderer::__createDeviceIndependentResources()
|
||||
bool e2d::Renderer::__createDeviceIndependentResources()
|
||||
{
|
||||
// 创建设备无关资源,它们的生命周期和程序的时长相同
|
||||
HRESULT hr = D2D1CreateFactory(
|
||||
|
|
@ -46,13 +46,13 @@ bool e2d::ERenderer::__createDeviceIndependentResources()
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
bool e2d::ERenderer::__createDeviceResources()
|
||||
bool e2d::Renderer::__createDeviceResources()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!s_pRenderTarget)
|
||||
{
|
||||
HWND hWnd = EWindow::getHWnd();
|
||||
HWND hWnd = Window::getHWnd();
|
||||
|
||||
// 创建设备相关资源。这些资源应在 Direct3D 设备消失时重建,
|
||||
// 比如当 isVisiable 被修改,等等
|
||||
|
|
@ -89,13 +89,13 @@ bool e2d::ERenderer::__createDeviceResources()
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void e2d::ERenderer::__discardDeviceResources()
|
||||
void e2d::Renderer::__discardDeviceResources()
|
||||
{
|
||||
SafeReleaseInterface(&s_pRenderTarget);
|
||||
SafeReleaseInterface(&s_pSolidBrush);
|
||||
}
|
||||
|
||||
void e2d::ERenderer::__discardResources()
|
||||
void e2d::Renderer::__discardResources()
|
||||
{
|
||||
SafeReleaseInterface(&s_pDirect2dFactory);
|
||||
SafeReleaseInterface(&s_pRenderTarget);
|
||||
|
|
@ -104,12 +104,12 @@ void e2d::ERenderer::__discardResources()
|
|||
SafeReleaseInterface(&s_pDWriteFactory);
|
||||
}
|
||||
|
||||
void e2d::ERenderer::__render()
|
||||
void e2d::Renderer::__render()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// 创建设备相关资源
|
||||
ERenderer::__createDeviceResources();
|
||||
Renderer::__createDeviceResources();
|
||||
|
||||
// 开始渲染
|
||||
s_pRenderTarget->BeginDraw();
|
||||
|
|
@ -117,7 +117,7 @@ void e2d::ERenderer::__render()
|
|||
s_pRenderTarget->Clear(s_nClearColor);
|
||||
|
||||
// 渲染场景
|
||||
ESceneManager::__render();
|
||||
SceneManager::__render();
|
||||
|
||||
// 终止渲染
|
||||
hr = s_pRenderTarget->EndDraw();
|
||||
|
|
@ -127,44 +127,44 @@ void e2d::ERenderer::__render()
|
|||
// 如果 Direct3D 设备在执行过程中消失,将丢弃当前的设备相关资源
|
||||
// 并在下一次调用时重建资源
|
||||
hr = S_OK;
|
||||
ERenderer::__discardDeviceResources();
|
||||
Renderer::__discardDeviceResources();
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// 渲染时产生了未知的错误,退出游戏
|
||||
ASSERT(false, L"Renderer error: %#X!", hr);
|
||||
EGame::quit();
|
||||
Game::quit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void e2d::ERenderer::setBackgroundColor(UINT32 color)
|
||||
void e2d::Renderer::setBackgroundColor(UINT32 color)
|
||||
{
|
||||
s_nClearColor = D2D1::ColorF(color);
|
||||
}
|
||||
|
||||
ID2D1Factory * e2d::ERenderer::getID2D1Factory()
|
||||
ID2D1Factory * e2d::Renderer::getID2D1Factory()
|
||||
{
|
||||
return s_pDirect2dFactory;
|
||||
}
|
||||
|
||||
ID2D1HwndRenderTarget * e2d::ERenderer::getRenderTarget()
|
||||
ID2D1HwndRenderTarget * e2d::Renderer::getRenderTarget()
|
||||
{
|
||||
return s_pRenderTarget;
|
||||
}
|
||||
|
||||
ID2D1SolidColorBrush * e2d::ERenderer::getSolidColorBrush()
|
||||
ID2D1SolidColorBrush * e2d::Renderer::getSolidColorBrush()
|
||||
{
|
||||
return s_pSolidBrush;
|
||||
}
|
||||
|
||||
IWICImagingFactory * e2d::ERenderer::getIWICImagingFactory()
|
||||
IWICImagingFactory * e2d::Renderer::getIWICImagingFactory()
|
||||
{
|
||||
return s_pIWICFactory;
|
||||
}
|
||||
|
||||
IDWriteFactory * e2d::ERenderer::getIDWriteFactory()
|
||||
IDWriteFactory * e2d::Renderer::getIDWriteFactory()
|
||||
{
|
||||
return s_pDWriteFactory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,39 +20,39 @@ static float s_fTotalTime = 0;
|
|||
static milliseconds s_tExceptedInvertal;
|
||||
|
||||
|
||||
float e2d::ETime::getTotalTime()
|
||||
float e2d::Time::getTotalTime()
|
||||
{
|
||||
return s_fTotalTime;
|
||||
}
|
||||
|
||||
int e2d::ETime::getDeltaTime()
|
||||
int e2d::Time::getDeltaTime()
|
||||
{
|
||||
return s_nInterval;
|
||||
}
|
||||
|
||||
bool e2d::ETime::__init()
|
||||
bool e2d::Time::__init()
|
||||
{
|
||||
s_tStart = s_tLastUpdate = s_tFixedUpdate = s_tNow = steady_clock::now();
|
||||
s_tExceptedInvertal = milliseconds(17);
|
||||
return true;
|
||||
}
|
||||
|
||||
void e2d::ETime::__uninit()
|
||||
void e2d::Time::__uninit()
|
||||
{
|
||||
}
|
||||
|
||||
bool e2d::ETime::__isReady()
|
||||
bool e2d::Time::__isReady()
|
||||
{
|
||||
return s_tExceptedInvertal < duration_cast<milliseconds>(s_tNow - s_tFixedUpdate);
|
||||
}
|
||||
|
||||
void e2d::ETime::__updateNow()
|
||||
void e2d::Time::__updateNow()
|
||||
{
|
||||
// Ë¢ÐÂʱ¼ä
|
||||
s_tNow = steady_clock::now();
|
||||
}
|
||||
|
||||
void e2d::ETime::__updateLast()
|
||||
void e2d::Time::__updateLast()
|
||||
{
|
||||
s_tFixedUpdate += s_tExceptedInvertal;
|
||||
s_tLastUpdate = s_tNow;
|
||||
|
|
@ -62,7 +62,7 @@ void e2d::ETime::__updateLast()
|
|||
s_fTotalTime = static_cast<float>(duration_cast<milliseconds>(s_tNow - s_tStart).count()) / 1000.0f;
|
||||
}
|
||||
|
||||
void e2d::ETime::__sleep()
|
||||
void e2d::Time::__sleep()
|
||||
{
|
||||
// ¼ÆËã¹ÒÆðʱ³¤
|
||||
int nWaitMS = 16 - static_cast<int>(duration_cast<milliseconds>(s_tNow - s_tFixedUpdate).count());
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ static HWND s_HWnd = nullptr;
|
|||
static bool s_bShowConsole = false;
|
||||
|
||||
|
||||
bool e2d::EWindow::__init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID /*= nullptr*/)
|
||||
bool e2d::Window::__init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID /*= nullptr*/)
|
||||
{
|
||||
// 注册窗口类
|
||||
WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = EWindow::WndProc;
|
||||
wcex.lpfnWndProc = Window::WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = sizeof(LONG_PTR);
|
||||
wcex.hInstance = HINST_THISCOMPONENT;
|
||||
|
|
@ -41,7 +41,7 @@ bool e2d::EWindow::__init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR
|
|||
FLOAT dpiX, dpiY;
|
||||
|
||||
// 工厂将返回当前的系统 DPI,这个值也将用来创建窗口
|
||||
ERenderer::getID2D1Factory()->GetDesktopDpi(&dpiX, &dpiY);
|
||||
Renderer::getID2D1Factory()->GetDesktopDpi(&dpiX, &dpiY);
|
||||
|
||||
nWidth = static_cast<UINT>(ceil(nWidth * dpiX / 96.f));
|
||||
nHeight = static_cast<UINT>(ceil(nHeight * dpiY / 96.f));
|
||||
|
|
@ -72,7 +72,7 @@ bool e2d::EWindow::__init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR
|
|||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// 禁用输入法
|
||||
EWindow::setTypewritingEnable(false);
|
||||
Window::setTypewritingEnable(false);
|
||||
// 查找是否存在控制台
|
||||
HWND hwnd = ::GetConsoleWindow();
|
||||
if (hwnd)
|
||||
|
|
@ -100,7 +100,7 @@ bool e2d::EWindow::__init(LPCTSTR sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void e2d::EWindow::__uninit()
|
||||
void e2d::Window::__uninit()
|
||||
{
|
||||
// 关闭控制台
|
||||
if (::GetConsoleWindow())
|
||||
|
|
@ -112,7 +112,7 @@ void e2d::EWindow::__uninit()
|
|||
s_HWnd = nullptr;
|
||||
}
|
||||
|
||||
void e2d::EWindow::__poll()
|
||||
void e2d::Window::__poll()
|
||||
{
|
||||
static MSG msg;
|
||||
|
||||
|
|
@ -123,28 +123,28 @@ void e2d::EWindow::__poll()
|
|||
}
|
||||
}
|
||||
|
||||
float e2d::EWindow::getWidth()
|
||||
float e2d::Window::getWidth()
|
||||
{
|
||||
return ERenderer::getRenderTarget()->GetSize().width;
|
||||
return Renderer::getRenderTarget()->GetSize().width;
|
||||
}
|
||||
|
||||
float e2d::EWindow::getHeight()
|
||||
float e2d::Window::getHeight()
|
||||
{
|
||||
return ERenderer::getRenderTarget()->GetSize().height;
|
||||
return Renderer::getRenderTarget()->GetSize().height;
|
||||
}
|
||||
|
||||
e2d::ESize e2d::EWindow::getSize()
|
||||
e2d::Size e2d::Window::getSize()
|
||||
{
|
||||
D2D1_SIZE_F size = ERenderer::getRenderTarget()->GetSize();
|
||||
return ESize(size.width, size.height);
|
||||
D2D1_SIZE_F size = Renderer::getRenderTarget()->GetSize();
|
||||
return Size(size.width, size.height);
|
||||
}
|
||||
|
||||
HWND e2d::EWindow::getHWnd()
|
||||
HWND e2d::Window::getHWnd()
|
||||
{
|
||||
return s_HWnd;
|
||||
}
|
||||
|
||||
void e2d::EWindow::setSize(UINT32 width, UINT32 height)
|
||||
void e2d::Window::setSize(UINT32 width, UINT32 height)
|
||||
{
|
||||
// 获取屏幕分辨率
|
||||
int screenWidth = ::GetSystemMetrics(SM_CXSCREEN);
|
||||
|
|
@ -162,20 +162,20 @@ void e2d::EWindow::setSize(UINT32 width, UINT32 height)
|
|||
::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE);
|
||||
}
|
||||
|
||||
void e2d::EWindow::setTitle(const EString &title)
|
||||
void e2d::Window::setTitle(const String &title)
|
||||
{
|
||||
// 设置窗口标题
|
||||
::SetWindowText(s_HWnd, title);
|
||||
}
|
||||
|
||||
e2d::EString e2d::EWindow::getTitle()
|
||||
e2d::String e2d::Window::getTitle()
|
||||
{
|
||||
wchar_t wszTitle[MAX_PATH] = { 0 };
|
||||
::GetWindowText(s_HWnd, wszTitle, MAX_PATH);
|
||||
return wszTitle;
|
||||
}
|
||||
|
||||
void e2d::EWindow::showConsole(bool show /* = true */)
|
||||
void e2d::Window::showConsole(bool show /* = true */)
|
||||
{
|
||||
s_bShowConsole = show;
|
||||
// 查找已存在的控制台句柄
|
||||
|
|
@ -217,7 +217,7 @@ void e2d::EWindow::showConsole(bool show /* = true */)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EWindow::setTypewritingEnable(bool bEnable)
|
||||
void e2d::Window::setTypewritingEnable(bool bEnable)
|
||||
{
|
||||
static HIMC hImc = nullptr;
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ void e2d::EWindow::setTypewritingEnable(bool bEnable)
|
|||
{
|
||||
if (hImc != nullptr)
|
||||
{
|
||||
::ImmAssociateContext(EWindow::getHWnd(), hImc);
|
||||
::ImmAssociateContext(Window::getHWnd(), hImc);
|
||||
hImc = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -233,13 +233,13 @@ void e2d::EWindow::setTypewritingEnable(bool bEnable)
|
|||
{
|
||||
if (hImc == nullptr)
|
||||
{
|
||||
hImc = ::ImmAssociateContext(EWindow::getHWnd(), nullptr);
|
||||
hImc = ::ImmAssociateContext(Window::getHWnd(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT e2d::EWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT result = 0;
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ LRESULT e2d::EWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
// 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染
|
||||
// 目标适当。它可能会调用失败,但是这里可以忽略有可能的
|
||||
// 错误,因为这个错误将在下一次调用 EndDraw 时产生
|
||||
ERenderer::getRenderTarget()->Resize(D2D1::SizeU(width, height));
|
||||
Renderer::getRenderTarget()->Resize(D2D1::SizeU(width, height));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ LRESULT e2d::EWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
// 重绘窗口
|
||||
case WM_PAINT:
|
||||
{
|
||||
e2d::ERenderer::__render();
|
||||
e2d::Renderer::__render();
|
||||
ValidateRect(hWnd, NULL);
|
||||
}
|
||||
result = 0;
|
||||
|
|
@ -278,10 +278,10 @@ LRESULT e2d::EWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
// 窗口关闭消息
|
||||
case WM_CLOSE:
|
||||
{
|
||||
e2d::EScene * pCurrentScene = e2d::ESceneManager::getCurrentScene();
|
||||
e2d::Scene * pCurrentScene = e2d::SceneManager::getCurrentScene();
|
||||
if (!pCurrentScene || pCurrentScene->onCloseWindow())
|
||||
{
|
||||
e2d::EGame::quit();
|
||||
e2d::Game::quit();
|
||||
DestroyWindow(hWnd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
#include "..\enodes.h"
|
||||
|
||||
e2d::EFont::EFont()
|
||||
e2d::Font::Font()
|
||||
: m_pTextFormat(nullptr)
|
||||
, m_Color(EColor::WHITE)
|
||||
, m_Color(Color::WHITE)
|
||||
, m_fFontSize(22)
|
||||
, m_FontWeight(EFontWeight::REGULAR)
|
||||
, m_FontWeight(FontWeight::REGULAR)
|
||||
, m_bItalic(false)
|
||||
, m_bRecreateNeeded(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EFont::EFont(EString fontFamily, float fontSize /* = 22 */, UINT32 color /* = EColor::WHITE */, UINT32 fontWeight, bool italic /* = false */)
|
||||
e2d::Font::Font(String fontFamily, float fontSize /* = 22 */, UINT32 color /* = EColor::WHITE */, UINT32 fontWeight, bool italic /* = false */)
|
||||
: m_pTextFormat(nullptr)
|
||||
, m_Color(EColor::WHITE)
|
||||
, m_Color(Color::WHITE)
|
||||
, m_fFontSize(22)
|
||||
, m_FontWeight(EFontWeight::REGULAR)
|
||||
, m_FontWeight(FontWeight::REGULAR)
|
||||
, m_bItalic(false)
|
||||
, m_bRecreateNeeded(true)
|
||||
{
|
||||
|
|
@ -25,65 +25,65 @@ e2d::EFont::EFont(EString fontFamily, float fontSize /* = 22 */, UINT32 color /*
|
|||
this->setItalic(italic);
|
||||
}
|
||||
|
||||
e2d::EFont::~EFont()
|
||||
e2d::Font::~Font()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTextFormat);
|
||||
}
|
||||
|
||||
float e2d::EFont::getFontSize() const
|
||||
float e2d::Font::getFontSize() const
|
||||
{
|
||||
return m_fFontSize;
|
||||
}
|
||||
|
||||
UINT32 e2d::EFont::getFontWeight() const
|
||||
UINT32 e2d::Font::getFontWeight() const
|
||||
{
|
||||
return m_FontWeight;
|
||||
}
|
||||
|
||||
UINT32 e2d::EFont::getColor() const
|
||||
UINT32 e2d::Font::getColor() const
|
||||
{
|
||||
return m_Color;
|
||||
}
|
||||
|
||||
bool e2d::EFont::isItalic() const
|
||||
bool e2d::Font::isItalic() const
|
||||
{
|
||||
return m_bItalic;
|
||||
}
|
||||
|
||||
void e2d::EFont::setFamily(const EString & fontFamily)
|
||||
void e2d::Font::setFamily(const String & fontFamily)
|
||||
{
|
||||
m_sFontFamily = fontFamily;
|
||||
m_bRecreateNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::EFont::setSize(float fontSize)
|
||||
void e2d::Font::setSize(float fontSize)
|
||||
{
|
||||
m_fFontSize = fontSize;
|
||||
m_bRecreateNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::EFont::setWeight(UINT32 fontWeight)
|
||||
void e2d::Font::setWeight(UINT32 fontWeight)
|
||||
{
|
||||
m_FontWeight = fontWeight;
|
||||
m_bRecreateNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::EFont::setColor(UINT32 color)
|
||||
void e2d::Font::setColor(UINT32 color)
|
||||
{
|
||||
m_Color = color;
|
||||
}
|
||||
|
||||
void e2d::EFont::setItalic(bool value)
|
||||
void e2d::Font::setItalic(bool value)
|
||||
{
|
||||
m_bItalic = value;
|
||||
m_bRecreateNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::EFont::_initTextFormat()
|
||||
void e2d::Font::_initTextFormat()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTextFormat);
|
||||
|
||||
HRESULT hr = ERenderer::getIDWriteFactory()->CreateTextFormat(
|
||||
HRESULT hr = Renderer::getIDWriteFactory()->CreateTextFormat(
|
||||
m_sFontFamily,
|
||||
NULL,
|
||||
DWRITE_FONT_WEIGHT(m_FontWeight),
|
||||
|
|
@ -97,7 +97,7 @@ void e2d::EFont::_initTextFormat()
|
|||
ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!");
|
||||
}
|
||||
|
||||
IDWriteTextFormat * e2d::EFont::_getTextFormat()
|
||||
IDWriteTextFormat * e2d::Font::_getTextFormat()
|
||||
{
|
||||
if (m_bRecreateNeeded)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
static std::map<size_t, ID2D1Bitmap*> s_mBitmapsFromFile;
|
||||
|
||||
|
||||
e2d::EImage::EImage()
|
||||
e2d::Image::Image()
|
||||
: m_pBitmap(nullptr)
|
||||
, m_fSourceClipX(0)
|
||||
, m_fSourceClipY(0)
|
||||
|
|
@ -13,31 +13,31 @@ e2d::EImage::EImage()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::EImage::EImage(LPCTSTR strFileName)
|
||||
e2d::Image::Image(LPCTSTR strFileName)
|
||||
{
|
||||
this->loadFrom(strFileName);
|
||||
}
|
||||
|
||||
e2d::EImage::EImage(LPCTSTR strFileName, float nClipX, float nClipY, float nClipWidth, float nClipHeight)
|
||||
e2d::Image::Image(LPCTSTR strFileName, float nClipX, float nClipY, float nClipWidth, float nClipHeight)
|
||||
{
|
||||
this->loadFrom(strFileName);
|
||||
this->clip(nClipX, nClipY, nClipWidth, nClipHeight);
|
||||
}
|
||||
|
||||
e2d::EImage::~EImage()
|
||||
e2d::Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::EImage::loadFrom(const EString & strFilePath)
|
||||
void e2d::Image::loadFrom(const String & strFilePath)
|
||||
{
|
||||
WARN_IF(strFilePath.isEmpty(), "EImage cannot load bitmap from NULL file name.");
|
||||
WARN_IF(strFilePath.isEmpty(), "Image cannot load bitmap from NULL file name.");
|
||||
|
||||
if (strFilePath.isEmpty())
|
||||
return;
|
||||
|
||||
if (!EImage::preload(strFilePath))
|
||||
if (!Image::preload(strFilePath))
|
||||
{
|
||||
WARN_IF(true, "Load EImage from file failed!");
|
||||
WARN_IF(true, "Load Image from file failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -47,13 +47,13 @@ void e2d::EImage::loadFrom(const EString & strFilePath)
|
|||
m_fSourceClipHeight = m_pBitmap->GetSize().height;
|
||||
}
|
||||
|
||||
void e2d::EImage::loadFrom(const EString & strFilePath, float x, float y, float width, float height)
|
||||
void e2d::Image::loadFrom(const String & strFilePath, float x, float y, float width, float height)
|
||||
{
|
||||
loadFrom(strFilePath);
|
||||
clip(x, y, width, height);
|
||||
}
|
||||
|
||||
void e2d::EImage::clip(float x, float y, float width, float height)
|
||||
void e2d::Image::clip(float x, float y, float width, float height)
|
||||
{
|
||||
if (m_pBitmap)
|
||||
{
|
||||
|
|
@ -64,22 +64,22 @@ void e2d::EImage::clip(float x, float y, float width, float height)
|
|||
}
|
||||
}
|
||||
|
||||
float e2d::EImage::getWidth() const
|
||||
float e2d::Image::getWidth() const
|
||||
{
|
||||
return m_fSourceClipWidth;
|
||||
}
|
||||
|
||||
float e2d::EImage::getHeight() const
|
||||
float e2d::Image::getHeight() const
|
||||
{
|
||||
return m_fSourceClipHeight;
|
||||
}
|
||||
|
||||
e2d::ESize e2d::EImage::getSize() const
|
||||
e2d::Size e2d::Image::getSize() const
|
||||
{
|
||||
return ESize(m_fSourceClipWidth, m_fSourceClipHeight);
|
||||
return Size(m_fSourceClipWidth, m_fSourceClipHeight);
|
||||
}
|
||||
|
||||
float e2d::EImage::getSourceWidth() const
|
||||
float e2d::Image::getSourceWidth() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
{
|
||||
|
|
@ -91,7 +91,7 @@ float e2d::EImage::getSourceWidth() const
|
|||
}
|
||||
}
|
||||
|
||||
float e2d::EImage::getSourceHeight() const
|
||||
float e2d::Image::getSourceHeight() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
{
|
||||
|
|
@ -103,34 +103,34 @@ float e2d::EImage::getSourceHeight() const
|
|||
}
|
||||
}
|
||||
|
||||
e2d::ESize e2d::EImage::getSourceSize() const
|
||||
e2d::Size e2d::Image::getSourceSize() const
|
||||
{
|
||||
if (m_pBitmap)
|
||||
{
|
||||
return ESize(getSourceWidth(), getSourceHeight());
|
||||
return Size(getSourceWidth(), getSourceHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
return ESize();
|
||||
return Size();
|
||||
}
|
||||
}
|
||||
|
||||
float e2d::EImage::getClipX() const
|
||||
float e2d::Image::getClipX() const
|
||||
{
|
||||
return m_fSourceClipX;
|
||||
}
|
||||
|
||||
float e2d::EImage::getClipY() const
|
||||
float e2d::Image::getClipY() const
|
||||
{
|
||||
return m_fSourceClipY;
|
||||
}
|
||||
|
||||
e2d::EPoint e2d::EImage::getClipPos() const
|
||||
e2d::Point e2d::Image::getClipPos() const
|
||||
{
|
||||
return EPoint(m_fSourceClipX, m_fSourceClipY);
|
||||
return Point(m_fSourceClipX, m_fSourceClipY);
|
||||
}
|
||||
|
||||
bool e2d::EImage::preload(const EString & fileName)
|
||||
bool e2d::Image::preload(const String & fileName)
|
||||
{
|
||||
if (s_mBitmapsFromFile.find(fileName.hash()) != s_mBitmapsFromFile.end())
|
||||
{
|
||||
|
|
@ -146,7 +146,7 @@ bool e2d::EImage::preload(const EString & fileName)
|
|||
ID2D1Bitmap *pBitmap = nullptr;
|
||||
|
||||
// 创建解码器
|
||||
hr = ERenderer::getIWICImagingFactory()->CreateDecoderFromFilename(
|
||||
hr = Renderer::getIWICImagingFactory()->CreateDecoderFromFilename(
|
||||
fileName,
|
||||
NULL,
|
||||
GENERIC_READ,
|
||||
|
|
@ -164,7 +164,7 @@ bool e2d::EImage::preload(const EString & fileName)
|
|||
{
|
||||
// 创建图片格式转换器
|
||||
// (DXGI_FORMAT_B8G8R8A8_UNORM + D2D1_ALPHA_MODE_PREMULTIPLIED).
|
||||
hr = ERenderer::getIWICImagingFactory()->CreateFormatConverter(&pConverter);
|
||||
hr = Renderer::getIWICImagingFactory()->CreateFormatConverter(&pConverter);
|
||||
}
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
|
@ -181,7 +181,7 @@ bool e2d::EImage::preload(const EString & fileName)
|
|||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// 从 WIC 位图创建一个 Direct2D 位图
|
||||
hr = ERenderer::getRenderTarget()->CreateBitmapFromWicBitmap(
|
||||
hr = Renderer::getRenderTarget()->CreateBitmapFromWicBitmap(
|
||||
pConverter,
|
||||
NULL,
|
||||
&pBitmap
|
||||
|
|
@ -206,7 +206,7 @@ bool e2d::EImage::preload(const EString & fileName)
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void e2d::EImage::clearCache()
|
||||
void e2d::Image::clearCache()
|
||||
{
|
||||
for (auto child : s_mBitmapsFromFile)
|
||||
{
|
||||
|
|
@ -215,7 +215,7 @@ void e2d::EImage::clearCache()
|
|||
s_mBitmapsFromFile.clear();
|
||||
}
|
||||
|
||||
ID2D1Bitmap * e2d::EImage::getBitmap()
|
||||
ID2D1Bitmap * e2d::Image::getBitmap()
|
||||
{
|
||||
return m_pBitmap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\emanagers.h"
|
||||
|
||||
e2d::EObject::EObject()
|
||||
e2d::Obj::Obj()
|
||||
: m_nRefCount(0)
|
||||
, m_bManaged(false)
|
||||
{
|
||||
EObjectManager::add(this); // 将该对象放入释放池中
|
||||
ObjectManager::add(this); // 将该对象放入释放池中
|
||||
}
|
||||
|
||||
e2d::EObject::~EObject()
|
||||
e2d::Obj::~Obj()
|
||||
{
|
||||
}
|
||||
|
||||
// 引用计数加一
|
||||
void e2d::EObject::retain()
|
||||
void e2d::Obj::retain()
|
||||
{
|
||||
m_nRefCount++;
|
||||
}
|
||||
|
||||
// 引用计数减一
|
||||
void e2d::EObject::release()
|
||||
void e2d::Obj::release()
|
||||
{
|
||||
m_nRefCount--;
|
||||
// 通知对象管理池刷新
|
||||
EObjectManager::notifyFlush();
|
||||
ObjectManager::notifyFlush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,39 +5,39 @@
|
|||
#include "..\eactions.h"
|
||||
#include <algorithm>
|
||||
|
||||
e2d::EScene::EScene()
|
||||
e2d::Scene::Scene()
|
||||
: m_bWillSave(true)
|
||||
, m_bAutoUpdate(true)
|
||||
, m_bSortNeeded(false)
|
||||
, m_bShapeVisiable(false)
|
||||
, m_pRoot(new ENode())
|
||||
, m_pRoot(new Node())
|
||||
{
|
||||
m_pRoot->retain();
|
||||
m_pRoot->_onEnter();
|
||||
m_pRoot->_setParentScene(this);
|
||||
m_pRoot->setPivot(0, 0);
|
||||
m_pRoot->_setSize(EWindow::getWidth(), EWindow::getHeight());
|
||||
m_pRoot->_setSize(Window::getWidth(), Window::getHeight());
|
||||
}
|
||||
|
||||
e2d::EScene::~EScene()
|
||||
e2d::Scene::~Scene()
|
||||
{
|
||||
SafeRelease(&m_pRoot);
|
||||
}
|
||||
|
||||
void e2d::EScene::_render()
|
||||
void e2d::Scene::_render()
|
||||
{
|
||||
m_pRoot->_render();
|
||||
|
||||
if (m_bShapeVisiable)
|
||||
{
|
||||
// 恢复矩阵转换
|
||||
ERenderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
Renderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
// 绘制所有几何图形
|
||||
m_pRoot->_drawShape();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EScene::_update()
|
||||
void e2d::Scene::_update()
|
||||
{
|
||||
// 执行 onUpdate 函数
|
||||
if (m_bAutoUpdate)
|
||||
|
|
@ -48,27 +48,27 @@ void e2d::EScene::_update()
|
|||
m_pRoot->_update();
|
||||
}
|
||||
|
||||
void e2d::EScene::setAutoUpdate(bool bAutoUpdate)
|
||||
void e2d::Scene::setAutoUpdate(bool bAutoUpdate)
|
||||
{
|
||||
m_bAutoUpdate = bAutoUpdate;
|
||||
}
|
||||
|
||||
void e2d::EScene::add(ENode * child, int order /* = 0 */)
|
||||
void e2d::Scene::add(Node * child, int order /* = 0 */)
|
||||
{
|
||||
m_pRoot->addChild(child, order);
|
||||
}
|
||||
|
||||
bool e2d::EScene::remove(ENode * child)
|
||||
bool e2d::Scene::remove(Node * child)
|
||||
{
|
||||
return m_pRoot->removeChild(child);
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::EScene::getRoot() const
|
||||
e2d::Node * e2d::Scene::getRoot() const
|
||||
{
|
||||
return m_pRoot;
|
||||
}
|
||||
|
||||
void e2d::EScene::setShapeVisiable(bool visiable)
|
||||
void e2d::Scene::setShapeVisiable(bool visiable)
|
||||
{
|
||||
m_bShapeVisiable = visiable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
using namespace e2d;
|
||||
|
||||
|
||||
EString::EString()
|
||||
String::String()
|
||||
{
|
||||
_size = 0;
|
||||
_string = new wchar_t[1];
|
||||
_string[0] = 0;
|
||||
}
|
||||
|
||||
e2d::EString::EString(const wchar_t ch)
|
||||
e2d::String::String(const wchar_t ch)
|
||||
{
|
||||
_size = 1;
|
||||
_string = new wchar_t[2];
|
||||
|
|
@ -18,7 +18,7 @@ e2d::EString::EString(const wchar_t ch)
|
|||
_string[1] = 0;
|
||||
}
|
||||
|
||||
EString::EString(const wchar_t *str)
|
||||
String::String(const wchar_t *str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
|
|
@ -34,14 +34,14 @@ EString::EString(const wchar_t *str)
|
|||
}
|
||||
}
|
||||
|
||||
EString::EString(EString && str)
|
||||
String::String(String && str)
|
||||
{
|
||||
_size = str._size;
|
||||
_string = str._string;
|
||||
str._string = nullptr;
|
||||
}
|
||||
|
||||
EString::EString(const EString &str)
|
||||
String::String(const String &str)
|
||||
{
|
||||
if (str._size)
|
||||
{
|
||||
|
|
@ -57,7 +57,7 @@ EString::EString(const EString &str)
|
|||
}
|
||||
}
|
||||
|
||||
e2d::EString::EString(const std::wstring &str)
|
||||
e2d::String::String(const std::wstring &str)
|
||||
{
|
||||
if (!str.empty())
|
||||
{
|
||||
|
|
@ -73,12 +73,12 @@ e2d::EString::EString(const std::wstring &str)
|
|||
}
|
||||
}
|
||||
|
||||
EString::~EString()
|
||||
String::~String()
|
||||
{
|
||||
delete[] _string;
|
||||
}
|
||||
|
||||
EString &EString::operator=(const wchar_t *str)
|
||||
String &String::operator=(const wchar_t *str)
|
||||
{
|
||||
if (_string == str)
|
||||
return *this;
|
||||
|
|
@ -99,7 +99,7 @@ EString &EString::operator=(const wchar_t *str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
EString &EString::operator=(const EString &str)
|
||||
String &String::operator=(const String &str)
|
||||
{
|
||||
if (_string == str._string)
|
||||
return *this;
|
||||
|
|
@ -120,7 +120,7 @@ EString &EString::operator=(const EString &str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
EString & e2d::EString::operator=(const std::wstring &str)
|
||||
String & e2d::String::operator=(const std::wstring &str)
|
||||
{
|
||||
if (!str.empty())
|
||||
{
|
||||
|
|
@ -138,7 +138,7 @@ EString & e2d::EString::operator=(const std::wstring &str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool EString::operator==(const wchar_t *str)
|
||||
bool String::operator==(const wchar_t *str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
|
|
@ -150,70 +150,70 @@ bool EString::operator==(const wchar_t *str)
|
|||
}
|
||||
}
|
||||
|
||||
bool EString::operator ==(const EString &str)
|
||||
bool String::operator ==(const String &str)
|
||||
{
|
||||
return (wcscmp(str._string, _string) == 0);
|
||||
}
|
||||
|
||||
bool e2d::EString::operator==(const std::wstring &str)
|
||||
bool e2d::String::operator==(const std::wstring &str)
|
||||
{
|
||||
return (str.compare(_string) == 0);
|
||||
}
|
||||
|
||||
bool e2d::EString::operator!=(const wchar_t *str)
|
||||
bool e2d::String::operator!=(const wchar_t *str)
|
||||
{
|
||||
return (wcscmp(str, _string) != 0);
|
||||
}
|
||||
|
||||
bool e2d::EString::operator!=(const EString &str)
|
||||
bool e2d::String::operator!=(const String &str)
|
||||
{
|
||||
return (wcscmp(str._string, _string) != 0);
|
||||
}
|
||||
|
||||
bool e2d::EString::operator!=(const std::wstring &str)
|
||||
bool e2d::String::operator!=(const std::wstring &str)
|
||||
{
|
||||
return (str.compare(_string) != 0);
|
||||
}
|
||||
|
||||
wchar_t &EString::operator[](int index)
|
||||
wchar_t &String::operator[](int index)
|
||||
{
|
||||
ASSERT(index >= 0 && index < _size, "EString subscript out of range");
|
||||
ASSERT(index >= 0 && index < _size, "String subscript out of range");
|
||||
return _string[index];
|
||||
}
|
||||
|
||||
EString EString::operator+(const wchar_t *str)
|
||||
String String::operator+(const wchar_t *str)
|
||||
{
|
||||
EString str_temp(*this);
|
||||
String str_temp(*this);
|
||||
|
||||
str_temp += str;
|
||||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
EString EString::operator+(const wchar_t x)
|
||||
String String::operator+(const wchar_t x)
|
||||
{
|
||||
EString str_temp(*this);
|
||||
String str_temp(*this);
|
||||
|
||||
str_temp += x;
|
||||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
EString EString::operator+(const EString &str)
|
||||
String String::operator+(const String &str)
|
||||
{
|
||||
EString str_temp(*this);
|
||||
String str_temp(*this);
|
||||
|
||||
str_temp += str;
|
||||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
EString e2d::EString::operator+(const std::wstring &str)
|
||||
String e2d::String::operator+(const std::wstring &str)
|
||||
{
|
||||
EString str_temp(*this);
|
||||
String str_temp(*this);
|
||||
|
||||
str_temp += str;
|
||||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
EString &EString::operator+=(const wchar_t x)
|
||||
String &String::operator+=(const wchar_t x)
|
||||
{
|
||||
wchar_t *str_temp = new wchar_t[_size + 2];
|
||||
if (_string) wcscpy_s(str_temp, _size + 2, _string);
|
||||
|
|
@ -226,7 +226,7 @@ EString &EString::operator+=(const wchar_t x)
|
|||
return *this;
|
||||
}
|
||||
|
||||
EString &EString::operator+=(const wchar_t *str)
|
||||
String &String::operator+=(const wchar_t *str)
|
||||
{
|
||||
if (!str) return *this;
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ EString &EString::operator+=(const wchar_t *str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
EString &EString::operator+=(const EString &str)
|
||||
String &String::operator+=(const String &str)
|
||||
{
|
||||
if (str._size == 0) return *this;
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ EString &EString::operator+=(const EString &str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
EString & e2d::EString::operator+=(const std::wstring &str)
|
||||
String & e2d::String::operator+=(const std::wstring &str)
|
||||
{
|
||||
if (str.length() == 0) return *this;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ EString & e2d::EString::operator+=(const std::wstring &str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool e2d::EString::operator<(EString const &str) const
|
||||
bool e2d::String::operator<(String const &str) const
|
||||
{
|
||||
for (int i = 0; i <= _size; i++)
|
||||
if (_string[i] != str._string[i])
|
||||
|
|
@ -279,7 +279,7 @@ bool e2d::EString::operator<(EString const &str) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool e2d::EString::operator<=(EString const &str) const
|
||||
bool e2d::String::operator<=(String const &str) const
|
||||
{
|
||||
for (int i = 0; i <= _size; i++)
|
||||
if (_string[i] != str._string[i])
|
||||
|
|
@ -287,7 +287,7 @@ bool e2d::EString::operator<=(EString const &str) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool e2d::EString::operator>(EString const &str) const
|
||||
bool e2d::String::operator>(String const &str) const
|
||||
{
|
||||
for (int i = 0; i <= _size; i++)
|
||||
if (_string[i] != str._string[i])
|
||||
|
|
@ -295,7 +295,7 @@ bool e2d::EString::operator>(EString const &str) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool e2d::EString::operator>=(EString const &str) const
|
||||
bool e2d::String::operator>=(String const &str) const
|
||||
{
|
||||
for (int i = 0; i <= _size; i++)
|
||||
if (_string[i] != str._string[i])
|
||||
|
|
@ -303,7 +303,7 @@ bool e2d::EString::operator>=(EString const &str) const
|
|||
return true;
|
||||
}
|
||||
|
||||
unsigned int e2d::EString::hash() const
|
||||
unsigned int e2d::String::hash() const
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
|
||||
|
|
@ -315,27 +315,27 @@ unsigned int e2d::EString::hash() const
|
|||
return (hash);
|
||||
}
|
||||
|
||||
EString e2d::operator+(const wchar_t ch, const EString &str)
|
||||
String e2d::operator+(const wchar_t ch, const String &str)
|
||||
{
|
||||
return std::move((EString(ch) + str));
|
||||
return std::move((String(ch) + str));
|
||||
}
|
||||
|
||||
EString e2d::operator+(const wchar_t *str1, const EString &str2)
|
||||
String e2d::operator+(const wchar_t *str1, const String &str2)
|
||||
{
|
||||
return std::move((EString(str1) + str2));
|
||||
return std::move((String(str1) + str2));
|
||||
}
|
||||
|
||||
EString e2d::operator+(const EString &str1, const EString &str2)
|
||||
String e2d::operator+(const String &str1, const String &str2)
|
||||
{
|
||||
return std::move((EString(str1) + str2));
|
||||
return std::move((String(str1) + str2));
|
||||
}
|
||||
|
||||
EString e2d::operator+(const std::wstring &str1, const EString &str2)
|
||||
String e2d::operator+(const std::wstring &str1, const String &str2)
|
||||
{
|
||||
return std::move((EString(str1) + str2));
|
||||
return std::move((String(str1) + str2));
|
||||
}
|
||||
|
||||
std::wistream & e2d::operator>>(std::wistream &cin, EString &str)
|
||||
std::wistream & e2d::operator>>(std::wistream &cin, String &str)
|
||||
{
|
||||
const int limit_string_size = 4096;
|
||||
|
||||
|
|
@ -347,9 +347,9 @@ std::wistream & e2d::operator>>(std::wistream &cin, EString &str)
|
|||
}
|
||||
|
||||
|
||||
EString e2d::EString::upper() const
|
||||
String e2d::String::upper() const
|
||||
{
|
||||
EString str(*this);
|
||||
String str(*this);
|
||||
|
||||
for (int i = 0; i < str._size; i++)
|
||||
if (str._string[i] >= L'a' && str._string[i] <= L'z')
|
||||
|
|
@ -358,9 +358,9 @@ EString e2d::EString::upper() const
|
|||
return std::move(str);
|
||||
}
|
||||
|
||||
EString e2d::EString::lower() const
|
||||
String e2d::String::lower() const
|
||||
{
|
||||
EString str(*this);
|
||||
String str(*this);
|
||||
|
||||
for (int i = 0; i < str._size; i++)
|
||||
str._string[i] = towlower(str._string[i]);
|
||||
|
|
@ -368,17 +368,17 @@ EString e2d::EString::lower() const
|
|||
return std::move(str);
|
||||
}
|
||||
|
||||
EString e2d::EString::sub(int offset, int count) const
|
||||
String e2d::String::sub(int offset, int count) const
|
||||
{
|
||||
if (_size == 0 || offset >= _size)
|
||||
return std::move(EString());
|
||||
return std::move(String());
|
||||
|
||||
offset = offset >= 0 ? offset : 0;
|
||||
|
||||
if (count < 0 || (offset + count) > _size)
|
||||
count = _size - offset;
|
||||
|
||||
EString str_temp;
|
||||
String str_temp;
|
||||
str_temp._string = new wchar_t[count + 1];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
|
|
@ -388,7 +388,7 @@ EString e2d::EString::sub(int offset, int count) const
|
|||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
int e2d::EString::findFirstOf(const wchar_t ch) const
|
||||
int e2d::String::findFirstOf(const wchar_t ch) const
|
||||
{
|
||||
for (int i = 0; i < _size; i++)
|
||||
if (_string[i] == ch)
|
||||
|
|
@ -397,7 +397,7 @@ int e2d::EString::findFirstOf(const wchar_t ch) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
int e2d::EString::findLastOf(const wchar_t ch) const
|
||||
int e2d::String::findLastOf(const wchar_t ch) const
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
|
|
@ -408,17 +408,17 @@ int e2d::EString::findLastOf(const wchar_t ch) const
|
|||
return index;
|
||||
}
|
||||
|
||||
EString & e2d::EString::append(const wchar_t ch)
|
||||
String & e2d::String::append(const wchar_t ch)
|
||||
{
|
||||
return (*this) += ch;
|
||||
}
|
||||
|
||||
EString & e2d::EString::append(const wchar_t * str)
|
||||
String & e2d::String::append(const wchar_t * str)
|
||||
{
|
||||
return (*this) += str;
|
||||
}
|
||||
|
||||
EString & e2d::EString::append(const EString & str)
|
||||
String & e2d::String::append(const String & str)
|
||||
{
|
||||
return (*this) += str;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\eactions.h"
|
||||
|
||||
static std::vector<e2d::EAction*> s_vActions;
|
||||
static std::vector<e2d::Action*> s_vActions;
|
||||
|
||||
|
||||
void e2d::EActionManager::addAction(EAction * pAction, ENode * pTargetNode)
|
||||
void e2d::ActionManager::_add(Action * pAction, Node * pTargetNode)
|
||||
{
|
||||
WARN_IF(pAction == nullptr, "EAction NULL pointer exception!");
|
||||
WARN_IF(pAction == nullptr, "Action NULL pointer exception!");
|
||||
|
||||
if (pAction)
|
||||
{
|
||||
|
|
@ -16,7 +16,7 @@ void e2d::EActionManager::addAction(EAction * pAction, ENode * pTargetNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::resumeAllActionsBindedWith(ENode * pTargetNode)
|
||||
void e2d::ActionManager::resumeAllActionsBindedWith(Node * pTargetNode)
|
||||
{
|
||||
if (pTargetNode)
|
||||
{
|
||||
|
|
@ -29,12 +29,12 @@ void e2d::EActionManager::resumeAllActionsBindedWith(ENode * pTargetNode)
|
|||
}
|
||||
for (auto child : pTargetNode->getChildren())
|
||||
{
|
||||
EActionManager::resumeAllActionsBindedWith(child);
|
||||
ActionManager::resumeAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::pauseAllActionsBindedWith(ENode * pTargetNode)
|
||||
void e2d::ActionManager::pauseAllActionsBindedWith(Node * pTargetNode)
|
||||
{
|
||||
if (pTargetNode)
|
||||
{
|
||||
|
|
@ -47,12 +47,12 @@ void e2d::EActionManager::pauseAllActionsBindedWith(ENode * pTargetNode)
|
|||
}
|
||||
for (auto child : pTargetNode->getChildren())
|
||||
{
|
||||
EActionManager::pauseAllActionsBindedWith(child);
|
||||
ActionManager::pauseAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::stopAllActionsBindedWith(ENode * pTargetNode)
|
||||
void e2d::ActionManager::stopAllActionsBindedWith(Node * pTargetNode)
|
||||
{
|
||||
if (pTargetNode)
|
||||
{
|
||||
|
|
@ -65,12 +65,12 @@ void e2d::EActionManager::stopAllActionsBindedWith(ENode * pTargetNode)
|
|||
}
|
||||
for (auto child : pTargetNode->getChildren())
|
||||
{
|
||||
EActionManager::stopAllActionsBindedWith(child);
|
||||
ActionManager::stopAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::__clearAllActionsBindedWith(ENode * pTargetNode)
|
||||
void e2d::ActionManager::__clearAllActionsBindedWith(Node * pTargetNode)
|
||||
{
|
||||
if (pTargetNode)
|
||||
{
|
||||
|
|
@ -90,31 +90,31 @@ void e2d::EActionManager::__clearAllActionsBindedWith(ENode * pTargetNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::resumeAllActions()
|
||||
void e2d::ActionManager::resumeAllActions()
|
||||
{
|
||||
for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
{
|
||||
EActionManager::resumeAllActionsBindedWith(child);
|
||||
ActionManager::resumeAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::pauseAllActions()
|
||||
void e2d::ActionManager::pauseAllActions()
|
||||
{
|
||||
for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
{
|
||||
EActionManager::pauseAllActionsBindedWith(child);
|
||||
ActionManager::pauseAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::stopAllActions()
|
||||
void e2d::ActionManager::stopAllActions()
|
||||
{
|
||||
for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren())
|
||||
{
|
||||
EActionManager::stopAllActionsBindedWith(child);
|
||||
ActionManager::stopAllActionsBindedWith(child);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::__resetAllActions()
|
||||
void e2d::ActionManager::__resetAllActions()
|
||||
{
|
||||
for (auto action : s_vActions)
|
||||
{
|
||||
|
|
@ -122,9 +122,9 @@ void e2d::EActionManager::__resetAllActions()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EActionManager::__update()
|
||||
void e2d::ActionManager::__update()
|
||||
{
|
||||
if (s_vActions.empty())
|
||||
if (s_vActions.empty() || Game::isPaused())
|
||||
return;
|
||||
|
||||
// 循环遍历所有正在运行的动作
|
||||
|
|
@ -134,7 +134,7 @@ void e2d::EActionManager::__update()
|
|||
// 获取动作运行状态
|
||||
if (action->isRunning() &&
|
||||
action->getTarget() &&
|
||||
action->getTarget()->getParentScene() == ESceneManager::getCurrentScene())
|
||||
action->getTarget()->getParentScene() == SceneManager::getCurrentScene())
|
||||
{
|
||||
if (!action->_isEnding())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
static IXAudio2 * s_pXAudio2 = nullptr;
|
||||
static IXAudio2MasteringVoice * s_pMasteringVoice = nullptr;
|
||||
|
||||
typedef std::pair<UINT, e2d::EMusic *> MusicPair;
|
||||
typedef std::map<UINT, e2d::EMusic *> MusicList;
|
||||
typedef std::pair<UINT, e2d::Music *> MusicPair;
|
||||
typedef std::map<UINT, e2d::Music *> MusicList;
|
||||
|
||||
static MusicList& getMusicList()
|
||||
{
|
||||
|
|
@ -15,9 +15,9 @@ static MusicList& getMusicList()
|
|||
}
|
||||
|
||||
|
||||
bool e2d::EMusicManager::add(const EString & strFilePath)
|
||||
bool e2d::MusicManager::add(const String & strFilePath)
|
||||
{
|
||||
EMusic * pPlayer = get(strFilePath);
|
||||
Music * pPlayer = get(strFilePath);
|
||||
if (pPlayer)
|
||||
{
|
||||
return true;
|
||||
|
|
@ -25,7 +25,7 @@ bool e2d::EMusicManager::add(const EString & strFilePath)
|
|||
else
|
||||
{
|
||||
UINT nRet = strFilePath.hash();
|
||||
pPlayer = new EMusic();
|
||||
pPlayer = new Music();
|
||||
|
||||
if (pPlayer->_open(strFilePath))
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ bool e2d::EMusicManager::add(const EString & strFilePath)
|
|||
}
|
||||
}
|
||||
|
||||
e2d::EMusic * e2d::EMusicManager::get(const EString & strFilePath)
|
||||
e2d::Music * e2d::MusicManager::get(const String & strFilePath)
|
||||
{
|
||||
if (strFilePath.isEmpty())
|
||||
return nullptr;
|
||||
|
|
@ -53,7 +53,7 @@ e2d::EMusic * e2d::EMusicManager::get(const EString & strFilePath)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void e2d::EMusicManager::pauseAllMusics()
|
||||
void e2d::MusicManager::pauseAllMusics()
|
||||
{
|
||||
for (auto iter : getMusicList())
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ void e2d::EMusicManager::pauseAllMusics()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EMusicManager::resumeAllMusics()
|
||||
void e2d::MusicManager::resumeAllMusics()
|
||||
{
|
||||
for (auto iter : getMusicList())
|
||||
{
|
||||
|
|
@ -69,7 +69,7 @@ void e2d::EMusicManager::resumeAllMusics()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EMusicManager::stopAllMusics()
|
||||
void e2d::MusicManager::stopAllMusics()
|
||||
{
|
||||
for (auto iter : getMusicList())
|
||||
{
|
||||
|
|
@ -77,17 +77,17 @@ void e2d::EMusicManager::stopAllMusics()
|
|||
}
|
||||
}
|
||||
|
||||
IXAudio2 * e2d::EMusicManager::getIXAudio2()
|
||||
IXAudio2 * e2d::MusicManager::getIXAudio2()
|
||||
{
|
||||
return s_pXAudio2;
|
||||
}
|
||||
|
||||
IXAudio2MasteringVoice * e2d::EMusicManager::getIXAudio2MasteringVoice()
|
||||
IXAudio2MasteringVoice * e2d::MusicManager::getIXAudio2MasteringVoice()
|
||||
{
|
||||
return s_pMasteringVoice;
|
||||
}
|
||||
|
||||
bool e2d::EMusicManager::__init()
|
||||
bool e2d::MusicManager::__init()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ bool e2d::EMusicManager::__init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void e2d::EMusicManager::__uninit()
|
||||
void e2d::MusicManager::__uninit()
|
||||
{
|
||||
for (auto iter : getMusicList())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\ebase.h"
|
||||
|
||||
// EObjectManager 释放池的实现机制:
|
||||
// ObjectManager 释放池的实现机制:
|
||||
// EObject 类中的引用计数(m_nRefCount)保证了指针的使用安全
|
||||
// 它记录了对象被使用的次数,当计数为 0 时,EObjectManager 会自动释放这个对象
|
||||
// 它记录了对象被使用的次数,当计数为 0 时,ObjectManager 会自动释放这个对象
|
||||
// 所有的 EObject 对象都应在被使用时(例如 Text 添加到了场景中)
|
||||
// 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数
|
||||
// 让其自动释放
|
||||
|
||||
// 释放池容器
|
||||
static std::vector<e2d::EObject*> s_vPool;
|
||||
static std::vector<e2d::Obj*> s_vPool;
|
||||
// 标志释放池执行状态
|
||||
static bool s_bNotifyed = false;
|
||||
|
||||
void e2d::EObjectManager::__flush()
|
||||
void e2d::ObjectManager::__flush()
|
||||
{
|
||||
if (!s_bNotifyed) return;
|
||||
|
||||
s_bNotifyed = false;
|
||||
// 创建迭代器
|
||||
static std::vector<e2d::EObject*>::iterator iter;
|
||||
static std::vector<e2d::Obj*>::iterator iter;
|
||||
// 循环遍历容器中的所有对象
|
||||
for (iter = s_vPool.begin(); iter != s_vPool.end();)
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ void e2d::EObjectManager::__flush()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EObjectManager::add(e2d::EObject * nptr)
|
||||
void e2d::ObjectManager::add(e2d::Obj * nptr)
|
||||
{
|
||||
if (!nptr->m_bManaged)
|
||||
{
|
||||
|
|
@ -46,7 +46,7 @@ void e2d::EObjectManager::add(e2d::EObject * nptr)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EObjectManager::notifyFlush()
|
||||
void e2d::ObjectManager::notifyFlush()
|
||||
{
|
||||
s_bNotifyed = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
#include "..\etransitions.h"
|
||||
#include <stack>
|
||||
|
||||
static e2d::EScene * s_pCurrentScene = nullptr;
|
||||
static e2d::EScene * s_pNextScene = nullptr;
|
||||
static e2d::ETransition * s_pTransition = nullptr;
|
||||
static std::stack<e2d::EScene*> s_SceneStack;
|
||||
static e2d::Scene * s_pCurrentScene = nullptr;
|
||||
static e2d::Scene * s_pNextScene = nullptr;
|
||||
static e2d::Transition * s_pTransition = nullptr;
|
||||
static std::stack<e2d::Scene*> s_SceneStack;
|
||||
|
||||
void e2d::ESceneManager::enterScene(EScene * scene, ETransition * transition /* = nullptr */, bool saveCurrentScene /* = true */)
|
||||
void e2d::SceneManager::enterScene(Scene * scene, Transition * transition /* = nullptr */, bool saveCurrentScene /* = true */)
|
||||
{
|
||||
ASSERT(scene != nullptr, "Next scene NULL pointer exception!");
|
||||
scene->retain();
|
||||
|
|
@ -33,7 +33,7 @@ void e2d::ESceneManager::enterScene(EScene * scene, ETransition * transition /*
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ESceneManager::backScene(ETransition * transition /* = nullptr */)
|
||||
void e2d::SceneManager::backScene(Transition * transition /* = nullptr */)
|
||||
{
|
||||
// 栈为空时,调用返回场景函数失败
|
||||
WARN_IF(s_SceneStack.size() == 0, "Scene stack now is empty!");
|
||||
|
|
@ -61,7 +61,7 @@ void e2d::ESceneManager::backScene(ETransition * transition /* = nullptr */)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ESceneManager::clearScene()
|
||||
void e2d::SceneManager::clearScene()
|
||||
{
|
||||
// 清空场景栈
|
||||
while (s_SceneStack.size())
|
||||
|
|
@ -72,17 +72,17 @@ void e2d::ESceneManager::clearScene()
|
|||
}
|
||||
}
|
||||
|
||||
e2d::EScene * e2d::ESceneManager::getCurrentScene()
|
||||
e2d::Scene * e2d::SceneManager::getCurrentScene()
|
||||
{
|
||||
return s_pCurrentScene;
|
||||
}
|
||||
|
||||
bool e2d::ESceneManager::isTransitioning()
|
||||
bool e2d::SceneManager::isTransitioning()
|
||||
{
|
||||
return s_pTransition != nullptr;
|
||||
}
|
||||
|
||||
void e2d::ESceneManager::__update()
|
||||
void e2d::SceneManager::__update()
|
||||
{
|
||||
// 更新场景内容
|
||||
if (s_pCurrentScene)
|
||||
|
|
@ -136,7 +136,7 @@ void e2d::ESceneManager::__update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ESceneManager::__render()
|
||||
void e2d::SceneManager::__render()
|
||||
{
|
||||
// 绘制当前场景
|
||||
if (s_pCurrentScene)
|
||||
|
|
@ -150,11 +150,11 @@ void e2d::ESceneManager::__render()
|
|||
}
|
||||
}
|
||||
|
||||
bool e2d::ESceneManager::__init()
|
||||
bool e2d::SceneManager::__init()
|
||||
{
|
||||
if (!s_pNextScene)
|
||||
{
|
||||
s_pNextScene = new EScene();
|
||||
s_pNextScene = new Scene();
|
||||
}
|
||||
|
||||
s_pCurrentScene = s_pNextScene;
|
||||
|
|
@ -163,10 +163,10 @@ bool e2d::ESceneManager::__init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void e2d::ESceneManager::__uninit()
|
||||
void e2d::SceneManager::__uninit()
|
||||
{
|
||||
SafeRelease(&s_pCurrentScene);
|
||||
SafeRelease(&s_pNextScene);
|
||||
SafeRelease(&s_pTransition);
|
||||
ESceneManager::clearScene();
|
||||
SceneManager::clearScene();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
#include "..\eshape.h"
|
||||
|
||||
// 形状集合
|
||||
std::vector<e2d::EShape*> s_vShapes;
|
||||
std::vector<e2d::Shape*> s_vShapes;
|
||||
|
||||
|
||||
void e2d::EShapeManager::__updateShape(e2d::EShape * pActiveShape)
|
||||
void e2d::ShapeManager::__updateShape(e2d::Shape * pActiveShape)
|
||||
{
|
||||
ENode* pActiveNode = pActiveShape->m_pParentNode;
|
||||
Node* pActiveNode = pActiveShape->m_pParentNode;
|
||||
if (pActiveNode)
|
||||
{
|
||||
// 获取节点所在场景
|
||||
EScene* pCurrentScene = pActiveNode->getParentScene();
|
||||
Scene* pCurrentScene = pActiveNode->getParentScene();
|
||||
// 判断与其他形状的交集情况
|
||||
for (auto pPassiveShape : s_vShapes)
|
||||
{
|
||||
|
|
@ -20,7 +20,7 @@ void e2d::EShapeManager::__updateShape(e2d::EShape * pActiveShape)
|
|||
if (pActiveShape->m_nCollisionBitmask & pPassiveShape->m_nCategoryBitmask)
|
||||
{
|
||||
// 获取被碰撞节点
|
||||
ENode* pPassiveNode = pPassiveShape->m_pParentNode;
|
||||
Node* pPassiveNode = pPassiveShape->m_pParentNode;
|
||||
// 判断两节点是否处于同一场景中
|
||||
if (pPassiveNode &&
|
||||
pPassiveNode != pActiveNode &&
|
||||
|
|
@ -29,7 +29,7 @@ void e2d::EShapeManager::__updateShape(e2d::EShape * pActiveShape)
|
|||
// 判断两形状交集情况
|
||||
int relation = pActiveShape->getRelationWith(pPassiveShape);
|
||||
// 忽略 UNKNOWN 和 DISJOINT 情况
|
||||
if (relation != ERelation::UNKNOWN && relation != ERelation::DISJOINT)
|
||||
if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT)
|
||||
{
|
||||
pActiveNode->onCollide(pPassiveNode, relation);
|
||||
pPassiveNode->onCollide(pActiveNode, pPassiveShape->getRelationWith(pActiveShape));
|
||||
|
|
@ -41,7 +41,7 @@ void e2d::EShapeManager::__updateShape(e2d::EShape * pActiveShape)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EShapeManager::__addShape(EShape * pShape)
|
||||
void e2d::ShapeManager::__addShape(Shape * pShape)
|
||||
{
|
||||
if (pShape)
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ void e2d::EShapeManager::__addShape(EShape * pShape)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EShapeManager::__delShape(EShape * pShape)
|
||||
void e2d::ShapeManager::__delShape(Shape * pShape)
|
||||
{
|
||||
if (pShape)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,49 +2,48 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
static std::vector<e2d::ETimer*> s_vTimers;
|
||||
static std::vector<e2d::Timer*> s_vTimers;
|
||||
|
||||
|
||||
void e2d::ETimerManager::__update()
|
||||
void e2d::TimerManager::__update()
|
||||
{
|
||||
if (s_vTimers.empty())
|
||||
if (s_vTimers.empty() || Game::isPaused())
|
||||
return;
|
||||
|
||||
for (size_t i = 0; i < s_vTimers.size(); i++)
|
||||
for (auto &timer : s_vTimers)
|
||||
{
|
||||
auto &t = s_vTimers[i];
|
||||
if (t->_isReady())
|
||||
if (timer->_isReady())
|
||||
{
|
||||
t->_callOn();
|
||||
timer->_callOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::bindTimer(ETimer * timer, EScene * pParentScene)
|
||||
void e2d::TimerManager::add(Timer * pTimer, Scene * pParentScene)
|
||||
{
|
||||
ETimerManager::bindTimer(timer, pParentScene->getRoot());
|
||||
TimerManager::add(pTimer, pParentScene->getRoot());
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::bindTimer(ETimer * timer, ENode * pParentNode)
|
||||
void e2d::TimerManager::add(Timer * pTimer, Node * pParentNode)
|
||||
{
|
||||
WARN_IF(timer == nullptr, "ETimer NULL pointer exception!");
|
||||
WARN_IF(pParentNode == nullptr, "Bind ETimer with a NULL ENode pointer!");
|
||||
WARN_IF(pTimer == nullptr, "Timer NULL pointer exception!");
|
||||
WARN_IF(pParentNode == nullptr, "Bind Timer with a NULL Node pointer!");
|
||||
|
||||
if (timer && pParentNode)
|
||||
if (pTimer && pParentNode)
|
||||
{
|
||||
ASSERT(
|
||||
!timer->m_pParentNode,
|
||||
"The timer is already binded, it cannot bind again!"
|
||||
!pTimer->m_pParentNode,
|
||||
"The timer is already binded, cannot be binded again!"
|
||||
);
|
||||
|
||||
timer->start();
|
||||
timer->retain();
|
||||
timer->m_pParentNode = pParentNode;
|
||||
s_vTimers.push_back(timer);
|
||||
pTimer->start();
|
||||
pTimer->retain();
|
||||
pTimer->m_pParentNode = pParentNode;
|
||||
s_vTimers.push_back(pTimer);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::startTimers(const EString & name)
|
||||
void e2d::TimerManager::startTimers(const String & name)
|
||||
{
|
||||
for (auto timer : s_vTimers)
|
||||
{
|
||||
|
|
@ -55,7 +54,7 @@ void e2d::ETimerManager::startTimers(const EString & name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::stopTimers(const EString & name)
|
||||
void e2d::TimerManager::stopTimers(const String & name)
|
||||
{
|
||||
for (auto timer : s_vTimers)
|
||||
{
|
||||
|
|
@ -66,9 +65,9 @@ void e2d::ETimerManager::stopTimers(const EString & name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::delTimers(const EString & name)
|
||||
void e2d::TimerManager::deleteTimers(const String & name)
|
||||
{
|
||||
std::vector<ETimer*>::iterator mIter;
|
||||
std::vector<Timer*>::iterator mIter;
|
||||
for (mIter = s_vTimers.begin(); mIter != s_vTimers.end();)
|
||||
{
|
||||
if ((*mIter)->getName() == name)
|
||||
|
|
@ -83,17 +82,17 @@ void e2d::ETimerManager::delTimers(const EString & name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::startAllTimersBindedWith(EScene * pParentScene)
|
||||
void e2d::TimerManager::startAllTimersBindedWith(Scene * pParentScene)
|
||||
{
|
||||
ETimerManager::startAllTimersBindedWith(pParentScene->getRoot());
|
||||
TimerManager::startAllTimersBindedWith(pParentScene->getRoot());
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::stopAllTimersBindedWith(EScene * pParentScene)
|
||||
void e2d::TimerManager::stopAllTimersBindedWith(Scene * pParentScene)
|
||||
{
|
||||
ETimerManager::stopAllTimersBindedWith(pParentScene->getRoot());
|
||||
TimerManager::stopAllTimersBindedWith(pParentScene->getRoot());
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::startAllTimersBindedWith(ENode * pParentNode)
|
||||
void e2d::TimerManager::startAllTimersBindedWith(Node * pParentNode)
|
||||
{
|
||||
for (auto timer : s_vTimers)
|
||||
{
|
||||
|
|
@ -104,11 +103,11 @@ void e2d::ETimerManager::startAllTimersBindedWith(ENode * pParentNode)
|
|||
}
|
||||
for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++)
|
||||
{
|
||||
ETimerManager::startAllTimersBindedWith((*child));
|
||||
TimerManager::startAllTimersBindedWith((*child));
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::stopAllTimersBindedWith(ENode * pParentNode)
|
||||
void e2d::TimerManager::stopAllTimersBindedWith(Node * pParentNode)
|
||||
{
|
||||
for (auto timer : s_vTimers)
|
||||
{
|
||||
|
|
@ -119,11 +118,11 @@ void e2d::ETimerManager::stopAllTimersBindedWith(ENode * pParentNode)
|
|||
}
|
||||
for (auto child : pParentNode->getChildren())
|
||||
{
|
||||
ETimerManager::stopAllTimersBindedWith(child);
|
||||
TimerManager::stopAllTimersBindedWith(child);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::__clearAllTimersBindedWith(ENode * pParentNode)
|
||||
void e2d::TimerManager::__clearAllTimersBindedWith(Node * pParentNode)
|
||||
{
|
||||
for (size_t i = 0; i < s_vTimers.size();)
|
||||
{
|
||||
|
|
@ -140,20 +139,20 @@ void e2d::ETimerManager::__clearAllTimersBindedWith(ENode * pParentNode)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::__resetAllTimers()
|
||||
void e2d::TimerManager::__resetAllTimers()
|
||||
{
|
||||
for (auto timer : s_vTimers)
|
||||
{
|
||||
timer->m_fLast = ETime::getTotalTime();
|
||||
timer->m_fLast = Time::getTotalTime();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::startAllTimers()
|
||||
void e2d::TimerManager::startAllTimers()
|
||||
{
|
||||
ETimerManager::startAllTimersBindedWith(ESceneManager::getCurrentScene());
|
||||
TimerManager::startAllTimersBindedWith(SceneManager::getCurrentScene());
|
||||
}
|
||||
|
||||
void e2d::ETimerManager::stopAllTimers()
|
||||
void e2d::TimerManager::stopAllTimers()
|
||||
{
|
||||
ETimerManager::stopAllTimersBindedWith(ESceneManager::getCurrentScene());
|
||||
TimerManager::stopAllTimersBindedWith(SceneManager::getCurrentScene());
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
|
||||
e2d::EButton::EButton()
|
||||
: m_Callback((const BtnClkCallback &)nullptr)
|
||||
, m_eBtnState(EButton::NORMAL)
|
||||
e2d::Button::Button()
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -13,9 +13,9 @@ e2d::EButton::EButton()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::EButton::EButton(ENode * normal, const BtnClkCallback & callback)
|
||||
: m_Callback((const BtnClkCallback &)nullptr)
|
||||
, m_eBtnState(EButton::NORMAL)
|
||||
e2d::Button::Button(Node * normal, const ButtonCallback & callback)
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -27,9 +27,9 @@ e2d::EButton::EButton(ENode * normal, const BtnClkCallback & callback)
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButton::EButton(ENode * normal, ENode * selected, const BtnClkCallback & callback)
|
||||
: m_Callback((const BtnClkCallback &)nullptr)
|
||||
, m_eBtnState(EButton::NORMAL)
|
||||
e2d::Button::Button(Node * normal, Node * selected, const ButtonCallback & callback)
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -42,9 +42,9 @@ e2d::EButton::EButton(ENode * normal, ENode * selected, const BtnClkCallback & c
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButton::EButton(ENode * normal, ENode * mouseover, ENode * selected, const BtnClkCallback & callback)
|
||||
: m_Callback((const BtnClkCallback &)nullptr)
|
||||
, m_eBtnState(EButton::NORMAL)
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const ButtonCallback & callback)
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -58,9 +58,9 @@ e2d::EButton::EButton(ENode * normal, ENode * mouseover, ENode * selected, const
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButton::EButton(ENode * normal, ENode * mouseover, ENode * selected, ENode * disabled, const BtnClkCallback & callback)
|
||||
: m_Callback((const BtnClkCallback &)nullptr)
|
||||
, m_eBtnState(EButton::NORMAL)
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const ButtonCallback & callback)
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -75,12 +75,12 @@ e2d::EButton::EButton(ENode * normal, ENode * mouseover, ENode * selected, ENode
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
bool e2d::EButton::isEnable() const
|
||||
bool e2d::Button::isEnable() const
|
||||
{
|
||||
return m_bEnable;
|
||||
}
|
||||
|
||||
void e2d::EButton::setNormal(ENode * normal)
|
||||
void e2d::Button::setNormal(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormal)
|
||||
{
|
||||
|
|
@ -102,7 +102,7 @@ void e2d::EButton::setNormal(ENode * normal)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::setMouseOver(ENode * mouseover)
|
||||
void e2d::Button::setMouseOver(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pNormal)
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ void e2d::EButton::setMouseOver(ENode * mouseover)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::setSelected(ENode * selected)
|
||||
void e2d::Button::setSelected(Node * selected)
|
||||
{
|
||||
if (selected != m_pNormal)
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ void e2d::EButton::setSelected(ENode * selected)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::setDisabled(ENode * disabled)
|
||||
void e2d::Button::setDisabled(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pNormal)
|
||||
{
|
||||
|
|
@ -162,7 +162,7 @@ void e2d::EButton::setDisabled(ENode * disabled)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::setEnable(bool bEnable)
|
||||
void e2d::Button::setEnable(bool bEnable)
|
||||
{
|
||||
if (m_bEnable != bEnable)
|
||||
{
|
||||
|
|
@ -171,52 +171,52 @@ void e2d::EButton::setEnable(bool bEnable)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::setCallback(const BtnClkCallback & callback)
|
||||
void e2d::Button::setCallback(const ButtonCallback & callback)
|
||||
{
|
||||
WARN_IF(m_pNormal == nullptr, "EButton cannot work without anything to show. Please set its normal displayed.");
|
||||
WARN_IF(m_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");
|
||||
|
||||
m_Callback = callback;
|
||||
}
|
||||
|
||||
void e2d::EButton::setPivotX(float pivotX)
|
||||
void e2d::Button::setPivotX(float pivotX)
|
||||
{
|
||||
ENode::setPivotX(pivotX);
|
||||
Node::setPivotX(pivotX);
|
||||
if (m_pNormal) m_pNormal->setPivotX(pivotX);
|
||||
if (m_pMouseover) m_pMouseover->setPivotX(pivotX);
|
||||
if (m_pSelected) m_pSelected->setPivotX(pivotX);
|
||||
if (m_pDisabled) m_pDisabled->setPivotX(pivotX);
|
||||
}
|
||||
|
||||
void e2d::EButton::setPivotY(float pivotY)
|
||||
void e2d::Button::setPivotY(float pivotY)
|
||||
{
|
||||
ENode::setPivotY(pivotY);
|
||||
Node::setPivotY(pivotY);
|
||||
if (m_pNormal) m_pNormal->setPivotY(pivotY);
|
||||
if (m_pMouseover) m_pMouseover->setPivotY(pivotY);
|
||||
if (m_pSelected) m_pSelected->setPivotY(pivotY);
|
||||
if (m_pDisabled) m_pDisabled->setPivotY(pivotY);
|
||||
}
|
||||
|
||||
void e2d::EButton::setPivot(float pivotX, float pivotY)
|
||||
void e2d::Button::setPivot(float pivotX, float pivotY)
|
||||
{
|
||||
ENode::setPivot(pivotX, pivotY);
|
||||
Node::setPivot(pivotX, pivotY);
|
||||
if (m_pNormal) m_pNormal->setPivot(pivotX, pivotY);
|
||||
if (m_pMouseover) m_pMouseover->setPivot(pivotX, pivotY);
|
||||
if (m_pSelected) m_pSelected->setPivot(pivotX, pivotY);
|
||||
if (m_pDisabled) m_pDisabled->setPivot(pivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::EButton::onFixedUpdate()
|
||||
void e2d::Button::onFixedUpdate()
|
||||
{
|
||||
if (ESceneManager::isTransitioning())
|
||||
if (SceneManager::isTransitioning())
|
||||
return;
|
||||
|
||||
if (m_bEnable && m_bVisiable && m_pNormal)
|
||||
{
|
||||
if (EInput::isMouseLButtonRelease())
|
||||
if (Input::isMouseLButtonRelease())
|
||||
{
|
||||
// 鼠标左键抬起时,判断鼠标坐标是否在按钮内部
|
||||
if (m_bIsSelected &&
|
||||
m_pNormal->isPointIn(EInput::getMousePos()))
|
||||
m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_runCallback();
|
||||
}
|
||||
|
|
@ -224,9 +224,9 @@ void e2d::EButton::onFixedUpdate()
|
|||
m_bIsSelected = false;
|
||||
}
|
||||
|
||||
if (EInput::isMouseLButtonPress())
|
||||
if (Input::isMouseLButtonPress())
|
||||
{
|
||||
if (m_pNormal->isPointIn(EInput::getMousePos()))
|
||||
if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
// 鼠标左键按下,且位于按钮内时,标记 m_bIsSelected 为 true
|
||||
m_bIsSelected = true;
|
||||
|
|
@ -234,25 +234,25 @@ void e2d::EButton::onFixedUpdate()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_bIsSelected && EInput::isMouseLButtonDown())
|
||||
if (m_bIsSelected && Input::isMouseLButtonDown())
|
||||
{
|
||||
if (m_pNormal->isPointIn(EInput::getMousePos()))
|
||||
if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(EButton::SELECTED);
|
||||
_setState(Button::SELECTED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m_pNormal->isPointIn(EInput::getMousePos()))
|
||||
else if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(EButton::MOUSEOVER);
|
||||
_setState(Button::MOUSEOVER);
|
||||
return;
|
||||
}
|
||||
|
||||
_setState(EButton::NORMAL);
|
||||
_setState(Button::NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::_setState(BTN_STATE state)
|
||||
void e2d::Button::_setState(BTN_STATE state)
|
||||
{
|
||||
if (m_eBtnState != state)
|
||||
{
|
||||
|
|
@ -261,7 +261,7 @@ void e2d::EButton::_setState(BTN_STATE state)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::_updateVisiable()
|
||||
void e2d::Button::_updateVisiable()
|
||||
{
|
||||
if (m_pNormal) m_pNormal->setVisiable(false);
|
||||
if (m_pMouseover) m_pMouseover->setVisiable(false);
|
||||
|
|
@ -270,11 +270,11 @@ void e2d::EButton::_updateVisiable()
|
|||
|
||||
if (m_bEnable)
|
||||
{
|
||||
if (m_eBtnState == EButton::SELECTED && m_pSelected)
|
||||
if (m_eBtnState == Button::SELECTED && m_pSelected)
|
||||
{
|
||||
m_pSelected->setVisiable(true);
|
||||
}
|
||||
else if (m_eBtnState == EButton::MOUSEOVER && m_pMouseover)
|
||||
else if (m_eBtnState == Button::MOUSEOVER && m_pMouseover)
|
||||
{
|
||||
m_pMouseover->setVisiable(true);
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ void e2d::EButton::_updateVisiable()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButton::_runCallback()
|
||||
void e2d::Button::_runCallback()
|
||||
{
|
||||
if (m_Callback)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "..\enodes.h"
|
||||
|
||||
e2d::EButtonToggle::EButtonToggle()
|
||||
: EButton()
|
||||
e2d::ButtonToggle::ButtonToggle()
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
|
|
@ -14,8 +14,8 @@ e2d::EButtonToggle::EButtonToggle()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNormal, const BtnClkCallback & callback)
|
||||
: EButton()
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, const ButtonCallback & callback)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
|
|
@ -31,8 +31,8 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNormal, ENode * toggleOnSelected, ENode * toggleOffSelected, const BtnClkCallback & callback)
|
||||
: EButton()
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, const ButtonCallback & callback)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
|
|
@ -50,8 +50,8 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNormal, ENode * toggleOnMouseOver, ENode * toggleOffMouseOver, ENode * toggleOnSelected, ENode * toggleOffSelected, const BtnClkCallback & callback)
|
||||
: EButton()
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, const ButtonCallback & callback)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
|
|
@ -71,8 +71,8 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNormal, ENode * toggleOnMouseOver, ENode * toggleOffMouseOver, ENode * toggleOnSelected, ENode * toggleOffSelected, ENode * toggleOnDisabled, ENode * toggleOffDisabled, const BtnClkCallback & callback)
|
||||
: EButton()
|
||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, const ButtonCallback & callback)
|
||||
: Button()
|
||||
, m_bState(true)
|
||||
, m_pNormalOn(nullptr)
|
||||
, m_pMouseoverOn(nullptr)
|
||||
|
|
@ -94,23 +94,12 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma
|
|||
this->setCallback(callback);
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::toggle()
|
||||
{
|
||||
// 设置按钮状态
|
||||
setState(!m_bState);
|
||||
// 执行回调函数
|
||||
if (m_Callback)
|
||||
{
|
||||
m_Callback();
|
||||
}
|
||||
}
|
||||
|
||||
bool e2d::EButtonToggle::getState() const
|
||||
bool e2d::ButtonToggle::getState() const
|
||||
{
|
||||
return m_bState;
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setState(bool bState)
|
||||
void e2d::ButtonToggle::setState(bool bState)
|
||||
{
|
||||
if (m_bState != bState)
|
||||
{
|
||||
|
|
@ -120,7 +109,7 @@ void e2d::EButtonToggle::setState(bool bState)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setNormal(ENode * normal)
|
||||
void e2d::ButtonToggle::setNormal(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormalOn)
|
||||
{
|
||||
|
|
@ -143,7 +132,7 @@ void e2d::EButtonToggle::setNormal(ENode * normal)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setMouseOver(ENode * mouseover)
|
||||
void e2d::ButtonToggle::setMouseOver(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pMouseoverOn)
|
||||
{
|
||||
|
|
@ -165,7 +154,7 @@ void e2d::EButtonToggle::setMouseOver(ENode * mouseover)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setSelected(ENode * selected)
|
||||
void e2d::ButtonToggle::setSelected(Node * selected)
|
||||
{
|
||||
if (selected != m_pSelectedOn)
|
||||
{
|
||||
|
|
@ -187,7 +176,7 @@ void e2d::EButtonToggle::setSelected(ENode * selected)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setDisabled(ENode * disabled)
|
||||
void e2d::ButtonToggle::setDisabled(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pDisabledOn)
|
||||
{
|
||||
|
|
@ -209,7 +198,7 @@ void e2d::EButtonToggle::setDisabled(ENode * disabled)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setNormalOff(ENode * normal)
|
||||
void e2d::ButtonToggle::setNormalOff(Node * normal)
|
||||
{
|
||||
if (normal != m_pNormalOff)
|
||||
{
|
||||
|
|
@ -231,7 +220,7 @@ void e2d::EButtonToggle::setNormalOff(ENode * normal)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setMouseOverOff(ENode * mouseover)
|
||||
void e2d::ButtonToggle::setMouseOverOff(Node * mouseover)
|
||||
{
|
||||
if (mouseover != m_pMouseoverOff)
|
||||
{
|
||||
|
|
@ -253,7 +242,7 @@ void e2d::EButtonToggle::setMouseOverOff(ENode * mouseover)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setSelectedOff(ENode * selected)
|
||||
void e2d::ButtonToggle::setSelectedOff(Node * selected)
|
||||
{
|
||||
if (selected != m_pSelectedOff)
|
||||
{
|
||||
|
|
@ -275,7 +264,7 @@ void e2d::EButtonToggle::setSelectedOff(ENode * selected)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setDisabledOff(ENode * disabled)
|
||||
void e2d::ButtonToggle::setDisabledOff(Node * disabled)
|
||||
{
|
||||
if (disabled != m_pDisabledOff)
|
||||
{
|
||||
|
|
@ -297,9 +286,9 @@ void e2d::EButtonToggle::setDisabledOff(ENode * disabled)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setPivotX(float pivotX)
|
||||
void e2d::ButtonToggle::setPivotX(float pivotX)
|
||||
{
|
||||
ENode::setPivotX(pivotX);
|
||||
Node::setPivotX(pivotX);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivotX(pivotX);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivotX(pivotX);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivotX(pivotX);
|
||||
|
|
@ -310,9 +299,9 @@ void e2d::EButtonToggle::setPivotX(float pivotX)
|
|||
if (m_pDisabledOff) m_pDisabledOff->setPivotX(pivotX);
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setPivotY(float pivotY)
|
||||
void e2d::ButtonToggle::setPivotY(float pivotY)
|
||||
{
|
||||
ENode::setPivotY(pivotY);
|
||||
Node::setPivotY(pivotY);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivotY(pivotY);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivotY(pivotY);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivotY(pivotY);
|
||||
|
|
@ -323,9 +312,9 @@ void e2d::EButtonToggle::setPivotY(float pivotY)
|
|||
if (m_pDisabledOff) m_pDisabledOff->setPivotY(pivotY);
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::setPivot(float pivotX, float pivotY)
|
||||
void e2d::ButtonToggle::setPivot(float pivotX, float pivotY)
|
||||
{
|
||||
ENode::setPivot(pivotX, pivotY);
|
||||
Node::setPivot(pivotX, pivotY);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivot(pivotX, pivotY);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivot(pivotX, pivotY);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivot(pivotX, pivotY);
|
||||
|
|
@ -336,7 +325,7 @@ void e2d::EButtonToggle::setPivot(float pivotX, float pivotY)
|
|||
if (m_pDisabledOff) m_pDisabledOff->setPivot(pivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::_updateState()
|
||||
void e2d::ButtonToggle::_updateState()
|
||||
{
|
||||
if (m_bState)
|
||||
{
|
||||
|
|
@ -364,7 +353,7 @@ void e2d::EButtonToggle::_updateState()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EButtonToggle::_runCallback()
|
||||
void e2d::ButtonToggle::_runCallback()
|
||||
{
|
||||
m_bState = !m_bState;
|
||||
_updateState();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "..\enodes.h"
|
||||
|
||||
e2d::EMenu::EMenu()
|
||||
e2d::Menu::Menu()
|
||||
: m_bEnable(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EMenu::EMenu(int number, EButton * button1, ...)
|
||||
e2d::Menu::Menu(int number, Button * button1, ...)
|
||||
: m_bEnable(true)
|
||||
{
|
||||
EButton ** ppButton = &button1;
|
||||
Button ** ppButton = &button1;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
|
|
@ -18,17 +18,17 @@ e2d::EMenu::EMenu(int number, EButton * button1, ...)
|
|||
}
|
||||
}
|
||||
|
||||
bool e2d::EMenu::isEnable() const
|
||||
bool e2d::Menu::isEnable() const
|
||||
{
|
||||
return m_bEnable;
|
||||
}
|
||||
|
||||
size_t e2d::EMenu::getButtonCount() const
|
||||
size_t e2d::Menu::getButtonCount() const
|
||||
{
|
||||
return m_vButtons.size();
|
||||
}
|
||||
|
||||
void e2d::EMenu::setEnable(bool enable)
|
||||
void e2d::Menu::setEnable(bool enable)
|
||||
{
|
||||
if (m_bEnable != enable)
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@ void e2d::EMenu::setEnable(bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EMenu::addButton(EButton * button)
|
||||
void e2d::Menu::addButton(Button * button)
|
||||
{
|
||||
if (button)
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ void e2d::EMenu::addButton(EButton * button)
|
|||
}
|
||||
}
|
||||
|
||||
bool e2d::EMenu::removeButton(EButton * button)
|
||||
bool e2d::Menu::removeButton(Button * button)
|
||||
{
|
||||
if (m_vButtons.empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
static float s_fDefaultPiovtX = 0;
|
||||
static float s_fDefaultPiovtY = 0;
|
||||
|
||||
e2d::ENode::ENode()
|
||||
e2d::Node::Node()
|
||||
: m_nOrder(0)
|
||||
, m_fScaleX(1.0f)
|
||||
, m_fScaleY(1.0f)
|
||||
|
|
@ -34,18 +34,18 @@ e2d::ENode::ENode()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::ENode::~ENode()
|
||||
e2d::Node::~Node()
|
||||
{
|
||||
ETimerManager::__clearAllTimersBindedWith(this);
|
||||
EActionManager::__clearAllActionsBindedWith(this);
|
||||
EShapeManager::__delShape(m_pShape);
|
||||
TimerManager::__clearAllTimersBindedWith(this);
|
||||
ActionManager::__clearAllActionsBindedWith(this);
|
||||
ShapeManager::__delShape(m_pShape);
|
||||
for (auto child : m_vChildren)
|
||||
{
|
||||
SafeRelease(&child);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_update()
|
||||
void e2d::Node::_update()
|
||||
{
|
||||
if (m_bTransformNeeded)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ void e2d::ENode::_update()
|
|||
std::sort(
|
||||
std::begin(m_vChildren),
|
||||
std::end(m_vChildren),
|
||||
[](ENode * n1, ENode * n2) {
|
||||
[](Node * n1, Node * n2) {
|
||||
return n1->getOrder() < n2->getOrder();
|
||||
}
|
||||
);
|
||||
|
|
@ -87,7 +87,7 @@ void e2d::ENode::_update()
|
|||
|
||||
if (m_bAutoUpdate)
|
||||
{
|
||||
if (!EGame::isPaused())
|
||||
if (!Game::isPaused())
|
||||
{
|
||||
this->onUpdate();
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ void e2d::ENode::_update()
|
|||
{
|
||||
if (m_bAutoUpdate)
|
||||
{
|
||||
if (!EGame::isPaused())
|
||||
if (!Game::isPaused())
|
||||
{
|
||||
this->onUpdate();
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ void e2d::ENode::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_render()
|
||||
void e2d::Node::_render()
|
||||
{
|
||||
if (!m_bVisiable)
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@ void e2d::ENode::_render()
|
|||
}
|
||||
|
||||
// 转换渲染器的二维矩阵
|
||||
ERenderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
Renderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
// 渲染自身
|
||||
this->onRender();
|
||||
|
||||
|
|
@ -148,13 +148,13 @@ void e2d::ENode::_render()
|
|||
else
|
||||
{
|
||||
// 转换渲染器的二维矩阵
|
||||
ERenderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
Renderer::getRenderTarget()->SetTransform(m_MatriFinal);
|
||||
// 渲染自身
|
||||
this->onRender();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_drawShape()
|
||||
void e2d::Node::_drawShape()
|
||||
{
|
||||
// 绘制自身的几何形状
|
||||
if (m_pShape && m_pShape->m_bIsVisiable)
|
||||
|
|
@ -169,7 +169,7 @@ void e2d::ENode::_drawShape()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_onEnter()
|
||||
void e2d::Node::_onEnter()
|
||||
{
|
||||
if (!this->m_bDisplayedInScene)
|
||||
{
|
||||
|
|
@ -183,7 +183,7 @@ void e2d::ENode::_onEnter()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_onExit()
|
||||
void e2d::Node::_onExit()
|
||||
{
|
||||
if (this->m_bDisplayedInScene)
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ void e2d::ENode::_onExit()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_updateTransform()
|
||||
void e2d::Node::_updateTransform()
|
||||
{
|
||||
// 计算中心点坐标
|
||||
D2D1_POINT_2F pivot = D2D1::Point2F(
|
||||
|
|
@ -229,7 +229,7 @@ void e2d::ENode::_updateTransform()
|
|||
m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
||||
}
|
||||
|
||||
void e2d::ENode::_updateChildrenTransform()
|
||||
void e2d::Node::_updateChildrenTransform()
|
||||
{
|
||||
for (auto child : m_vChildren)
|
||||
{
|
||||
|
|
@ -237,7 +237,7 @@ void e2d::ENode::_updateChildrenTransform()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_updateTransform(ENode * node)
|
||||
void e2d::Node::_updateTransform(Node * node)
|
||||
{
|
||||
// 计算自身的转换矩阵
|
||||
node->_updateTransform();
|
||||
|
|
@ -252,7 +252,7 @@ void e2d::ENode::_updateTransform(ENode * node)
|
|||
node->m_bTransformNeeded = false;
|
||||
}
|
||||
|
||||
void e2d::ENode::_updateChildrenOpacity()
|
||||
void e2d::Node::_updateChildrenOpacity()
|
||||
{
|
||||
for (auto child : m_vChildren)
|
||||
{
|
||||
|
|
@ -260,7 +260,7 @@ void e2d::ENode::_updateChildrenOpacity()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_updateOpacity(ENode * node)
|
||||
void e2d::Node::_updateOpacity(Node * node)
|
||||
{
|
||||
if (node->m_pParent)
|
||||
{
|
||||
|
|
@ -269,132 +269,132 @@ void e2d::ENode::_updateOpacity(ENode * node)
|
|||
node->_updateChildrenOpacity();
|
||||
}
|
||||
|
||||
bool e2d::ENode::isVisiable() const
|
||||
bool e2d::Node::isVisiable() const
|
||||
{
|
||||
return m_bVisiable;
|
||||
}
|
||||
|
||||
e2d::EString e2d::ENode::getName() const
|
||||
e2d::String e2d::Node::getName() const
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
float e2d::ENode::getPosX() const
|
||||
float e2d::Node::getPosX() const
|
||||
{
|
||||
return m_Pos.x;
|
||||
}
|
||||
|
||||
float e2d::ENode::getPosY() const
|
||||
float e2d::Node::getPosY() const
|
||||
{
|
||||
return m_Pos.y;
|
||||
}
|
||||
|
||||
e2d::EPoint e2d::ENode::getPos() const
|
||||
e2d::Point e2d::Node::getPos() const
|
||||
{
|
||||
return m_Pos;
|
||||
}
|
||||
|
||||
float e2d::ENode::getWidth() const
|
||||
float e2d::Node::getWidth() const
|
||||
{
|
||||
return m_Size.width * m_fScaleX;
|
||||
}
|
||||
|
||||
float e2d::ENode::getHeight() const
|
||||
float e2d::Node::getHeight() const
|
||||
{
|
||||
return m_Size.height * m_fScaleY;
|
||||
}
|
||||
|
||||
float e2d::ENode::getRealWidth() const
|
||||
float e2d::Node::getRealWidth() const
|
||||
{
|
||||
return m_Size.width;
|
||||
}
|
||||
|
||||
float e2d::ENode::getRealHeight() const
|
||||
float e2d::Node::getRealHeight() const
|
||||
{
|
||||
return m_Size.height;
|
||||
}
|
||||
|
||||
e2d::ESize e2d::ENode::getRealSize() const
|
||||
e2d::Size e2d::Node::getRealSize() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
float e2d::ENode::getPivotX() const
|
||||
float e2d::Node::getPivotX() const
|
||||
{
|
||||
return m_fPivotX;
|
||||
}
|
||||
|
||||
float e2d::ENode::getPivotY() const
|
||||
float e2d::Node::getPivotY() const
|
||||
{
|
||||
return m_fPivotY;
|
||||
}
|
||||
|
||||
e2d::ESize e2d::ENode::getSize() const
|
||||
e2d::Size e2d::Node::getSize() const
|
||||
{
|
||||
return ESize(getWidth(), getHeight());
|
||||
return Size(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
float e2d::ENode::getScaleX() const
|
||||
float e2d::Node::getScaleX() const
|
||||
{
|
||||
return m_fScaleX;
|
||||
}
|
||||
|
||||
float e2d::ENode::getScaleY() const
|
||||
float e2d::Node::getScaleY() const
|
||||
{
|
||||
return m_fScaleY;
|
||||
}
|
||||
|
||||
float e2d::ENode::getSkewX() const
|
||||
float e2d::Node::getSkewX() const
|
||||
{
|
||||
return m_fSkewAngleX;
|
||||
}
|
||||
|
||||
float e2d::ENode::getSkewY() const
|
||||
float e2d::Node::getSkewY() const
|
||||
{
|
||||
return m_fSkewAngleY;
|
||||
}
|
||||
|
||||
float e2d::ENode::getRotation() const
|
||||
float e2d::Node::getRotation() const
|
||||
{
|
||||
return m_fRotation;
|
||||
}
|
||||
|
||||
float e2d::ENode::getOpacity() const
|
||||
float e2d::Node::getOpacity() const
|
||||
{
|
||||
return m_fRealOpacity;
|
||||
}
|
||||
|
||||
e2d::EShape * e2d::ENode::getShape() const
|
||||
e2d::Shape * e2d::Node::getShape() const
|
||||
{
|
||||
return m_pShape;
|
||||
}
|
||||
|
||||
int e2d::ENode::getOrder() const
|
||||
int e2d::Node::getOrder() const
|
||||
{
|
||||
return m_nOrder;
|
||||
}
|
||||
|
||||
void e2d::ENode::setOrder(int order)
|
||||
void e2d::Node::setOrder(int order)
|
||||
{
|
||||
m_nOrder = order;
|
||||
}
|
||||
|
||||
void e2d::ENode::setPosX(float x)
|
||||
void e2d::Node::setPosX(float x)
|
||||
{
|
||||
this->setPos(x, m_Pos.y);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPosY(float y)
|
||||
void e2d::Node::setPosY(float y)
|
||||
{
|
||||
this->setPos(m_Pos.x, y);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPos(const EPoint & p)
|
||||
void e2d::Node::setPos(const Point & p)
|
||||
{
|
||||
this->setPos(p.x, p.y);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPos(float x, float y)
|
||||
void e2d::Node::setPos(float x, float y)
|
||||
{
|
||||
if (m_Pos.x == x && m_Pos.y == y)
|
||||
return;
|
||||
|
|
@ -404,27 +404,27 @@ void e2d::ENode::setPos(float x, float y)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::movePosX(float x)
|
||||
void e2d::Node::movePosX(float x)
|
||||
{
|
||||
this->movePos(x, 0);
|
||||
}
|
||||
|
||||
void e2d::ENode::movePosY(float y)
|
||||
void e2d::Node::movePosY(float y)
|
||||
{
|
||||
this->movePos(0, y);
|
||||
}
|
||||
|
||||
void e2d::ENode::movePos(float x, float y)
|
||||
void e2d::Node::movePos(float x, float y)
|
||||
{
|
||||
this->setPos(m_Pos.x + x, m_Pos.y + y);
|
||||
}
|
||||
|
||||
void e2d::ENode::movePos(const EVector2 & v)
|
||||
void e2d::Node::movePos(const Vector & v)
|
||||
{
|
||||
this->movePos(v.x, v.y);
|
||||
}
|
||||
|
||||
void e2d::ENode::_setSize(float width, float height)
|
||||
void e2d::Node::_setSize(float width, float height)
|
||||
{
|
||||
if (m_Size.width == width && m_Size.height == height)
|
||||
return;
|
||||
|
|
@ -434,22 +434,22 @@ void e2d::ENode::_setSize(float width, float height)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::setScaleX(float scaleX)
|
||||
void e2d::Node::setScaleX(float scaleX)
|
||||
{
|
||||
this->setScale(scaleX, m_fScaleY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setScaleY(float scaleY)
|
||||
void e2d::Node::setScaleY(float scaleY)
|
||||
{
|
||||
this->setScale(m_fScaleX, scaleY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setScale(float scale)
|
||||
void e2d::Node::setScale(float scale)
|
||||
{
|
||||
this->setScale(scale, scale);
|
||||
}
|
||||
|
||||
void e2d::ENode::setScale(float scaleX, float scaleY)
|
||||
void e2d::Node::setScale(float scaleX, float scaleY)
|
||||
{
|
||||
if (m_fScaleX == scaleX && m_fScaleY == scaleY)
|
||||
return;
|
||||
|
|
@ -459,17 +459,17 @@ void e2d::ENode::setScale(float scaleX, float scaleY)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::setSkewX(float angleX)
|
||||
void e2d::Node::setSkewX(float angleX)
|
||||
{
|
||||
this->setSkew(angleX, m_fSkewAngleY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setSkewY(float angleY)
|
||||
void e2d::Node::setSkewY(float angleY)
|
||||
{
|
||||
this->setSkew(m_fSkewAngleX, angleY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setSkew(float angleX, float angleY)
|
||||
void e2d::Node::setSkew(float angleX, float angleY)
|
||||
{
|
||||
if (m_fSkewAngleX == angleX && m_fSkewAngleY == angleY)
|
||||
return;
|
||||
|
|
@ -479,7 +479,7 @@ void e2d::ENode::setSkew(float angleX, float angleY)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::setRotation(float angle)
|
||||
void e2d::Node::setRotation(float angle)
|
||||
{
|
||||
if (m_fRotation == angle)
|
||||
return;
|
||||
|
|
@ -488,7 +488,7 @@ void e2d::ENode::setRotation(float angle)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::setOpacity(float opacity)
|
||||
void e2d::Node::setOpacity(float opacity)
|
||||
{
|
||||
if (m_fRealOpacity == opacity)
|
||||
return;
|
||||
|
|
@ -498,17 +498,17 @@ void e2d::ENode::setOpacity(float opacity)
|
|||
_updateOpacity(this);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPivotX(float pivotX)
|
||||
void e2d::Node::setPivotX(float pivotX)
|
||||
{
|
||||
this->setPivot(pivotX, m_fPivotY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPivotY(float pivotY)
|
||||
void e2d::Node::setPivotY(float pivotY)
|
||||
{
|
||||
this->setPivot(m_fPivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::ENode::setPivot(float pivotX, float pivotY)
|
||||
void e2d::Node::setPivot(float pivotX, float pivotY)
|
||||
{
|
||||
if (m_fPivotX == pivotX && m_fPivotY == pivotY)
|
||||
return;
|
||||
|
|
@ -518,12 +518,12 @@ void e2d::ENode::setPivot(float pivotX, float pivotY)
|
|||
m_bTransformNeeded = true;
|
||||
}
|
||||
|
||||
void e2d::ENode::setShape(EShape * pShape)
|
||||
void e2d::Node::setShape(Shape * pShape)
|
||||
{
|
||||
// 删除旧的形状
|
||||
EShapeManager::__delShape(m_pShape);
|
||||
ShapeManager::__delShape(m_pShape);
|
||||
// 添加新的形状
|
||||
EShapeManager::__addShape(pShape);
|
||||
ShapeManager::__addShape(pShape);
|
||||
|
||||
if (pShape)
|
||||
{
|
||||
|
|
@ -537,17 +537,17 @@ void e2d::ENode::setShape(EShape * pShape)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::addChild(ENode * child, int order /* = 0 */)
|
||||
void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
||||
{
|
||||
WARN_IF(child == nullptr, "ENode::addChild NULL pointer exception.");
|
||||
WARN_IF(child == nullptr, "Node::addChild NULL pointer exception.");
|
||||
|
||||
if (child)
|
||||
{
|
||||
ASSERT(child->m_pParent == nullptr, "ENode already added. It can't be added again!");
|
||||
ASSERT(child->m_pParent == nullptr, "Node already added. It can't be added again!");
|
||||
|
||||
for (ENode * parent = this; parent != nullptr; parent = parent->getParent())
|
||||
for (Node * parent = this; parent != nullptr; parent = parent->getParent())
|
||||
{
|
||||
ASSERT(child != parent, "A ENode 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);
|
||||
|
|
@ -577,29 +577,29 @@ void e2d::ENode::addChild(ENode * child, int order /* = 0 */)
|
|||
}
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::ENode::getParent() const
|
||||
e2d::Node * e2d::Node::getParent() const
|
||||
{
|
||||
return m_pParent;
|
||||
}
|
||||
|
||||
e2d::EScene * e2d::ENode::getParentScene() const
|
||||
e2d::Scene * e2d::Node::getParentScene() const
|
||||
{
|
||||
return m_pParentScene;
|
||||
}
|
||||
|
||||
std::vector<e2d::ENode*>& e2d::ENode::getChildren()
|
||||
std::vector<e2d::Node*>& e2d::Node::getChildren()
|
||||
{
|
||||
return m_vChildren;
|
||||
}
|
||||
|
||||
int e2d::ENode::getChildrenCount() const
|
||||
int e2d::Node::getChildrenCount() const
|
||||
{
|
||||
return static_cast<int>(m_vChildren.size());
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::ENode::getChild(const EString & name)
|
||||
e2d::Node * e2d::Node::getChild(const String & name)
|
||||
{
|
||||
WARN_IF(name.isEmpty(), "Invalid ENode name.");
|
||||
WARN_IF(name.isEmpty(), "Invalid Node name.");
|
||||
|
||||
unsigned int hash = name.hash();
|
||||
|
||||
|
|
@ -612,11 +612,11 @@ e2d::ENode * e2d::ENode::getChild(const EString & name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<e2d::ENode*> e2d::ENode::getChildren(const EString & name)
|
||||
std::vector<e2d::Node*> e2d::Node::getChildren(const String & name)
|
||||
{
|
||||
std::vector<ENode*> vChildren;
|
||||
std::vector<Node*> vChildren;
|
||||
|
||||
WARN_IF(name.isEmpty(), "Invalid ENode name.");
|
||||
WARN_IF(name.isEmpty(), "Invalid Node name.");
|
||||
|
||||
unsigned int hash = name.hash();
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ std::vector<e2d::ENode*> e2d::ENode::getChildren(const EString & name)
|
|||
return std::move(vChildren);
|
||||
}
|
||||
|
||||
void e2d::ENode::removeFromParent()
|
||||
void e2d::Node::removeFromParent()
|
||||
{
|
||||
if (m_pParent)
|
||||
{
|
||||
|
|
@ -635,9 +635,9 @@ void e2d::ENode::removeFromParent()
|
|||
}
|
||||
}
|
||||
|
||||
bool e2d::ENode::removeChild(ENode * child)
|
||||
bool e2d::Node::removeChild(Node * child)
|
||||
{
|
||||
WARN_IF(child == nullptr, "ENode::removeChildren NULL pointer exception.");
|
||||
WARN_IF(child == nullptr, "Node::removeChildren NULL pointer exception.");
|
||||
|
||||
if (m_vChildren.empty())
|
||||
{
|
||||
|
|
@ -671,9 +671,9 @@ bool e2d::ENode::removeChild(ENode * child)
|
|||
return false;
|
||||
}
|
||||
|
||||
void e2d::ENode::removeChildren(const EString & childName)
|
||||
void e2d::Node::removeChildren(const String & childName)
|
||||
{
|
||||
WARN_IF(childName.isEmpty(), "Invalid ENode name.");
|
||||
WARN_IF(childName.isEmpty(), "Invalid Node name.");
|
||||
|
||||
if (m_vChildren.empty())
|
||||
{
|
||||
|
|
@ -704,7 +704,7 @@ void e2d::ENode::removeChildren(const EString & childName)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::clearAllChildren()
|
||||
void e2d::Node::clearAllChildren()
|
||||
{
|
||||
// 所有节点的引用计数减一
|
||||
for (auto child : m_vChildren)
|
||||
|
|
@ -719,7 +719,7 @@ void e2d::ENode::clearAllChildren()
|
|||
m_vChildren.clear();
|
||||
}
|
||||
|
||||
void e2d::ENode::runAction(EAction * action)
|
||||
void e2d::Node::runAction(Action * action)
|
||||
{
|
||||
if (this != action->getTarget())
|
||||
{
|
||||
|
|
@ -732,7 +732,7 @@ void e2d::ENode::runAction(EAction * action)
|
|||
{
|
||||
action = action->clone();
|
||||
}
|
||||
EActionManager::addAction(action, this);
|
||||
ActionManager::_add(action, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -740,7 +740,7 @@ void e2d::ENode::runAction(EAction * action)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::resumeAction(EAction * action)
|
||||
void e2d::Node::resumeAction(Action * action)
|
||||
{
|
||||
if (action->getTarget() == this)
|
||||
{
|
||||
|
|
@ -748,7 +748,7 @@ void e2d::ENode::resumeAction(EAction * action)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::pauseAction(EAction * action)
|
||||
void e2d::Node::pauseAction(Action * action)
|
||||
{
|
||||
if (action->getTarget() == this)
|
||||
{
|
||||
|
|
@ -756,7 +756,7 @@ void e2d::ENode::pauseAction(EAction * action)
|
|||
}
|
||||
}
|
||||
|
||||
bool e2d::ENode::isPointIn(EPoint point)
|
||||
bool e2d::Node::isPointIn(Point point)
|
||||
{
|
||||
if (m_bTransformNeeded)
|
||||
{
|
||||
|
|
@ -764,7 +764,7 @@ bool e2d::ENode::isPointIn(EPoint point)
|
|||
}
|
||||
// 为节点创建一个形状
|
||||
ID2D1RectangleGeometry * rect;
|
||||
ERenderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(0, 0, getWidth(), getHeight()),
|
||||
&rect
|
||||
);
|
||||
|
|
@ -788,18 +788,18 @@ bool e2d::ENode::isPointIn(EPoint point)
|
|||
return false;
|
||||
}
|
||||
|
||||
void e2d::ENode::setAutoUpdate(bool bAutoUpdate)
|
||||
void e2d::Node::setAutoUpdate(bool bAutoUpdate)
|
||||
{
|
||||
m_bAutoUpdate = bAutoUpdate;
|
||||
}
|
||||
|
||||
void e2d::ENode::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY)
|
||||
void e2d::Node::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY)
|
||||
{
|
||||
s_fDefaultPiovtX = min(max(defaultPiovtX, 0), 1);
|
||||
s_fDefaultPiovtY = min(max(defaultPiovtY, 0), 1);
|
||||
}
|
||||
|
||||
void e2d::ENode::stopAction(EAction * action)
|
||||
void e2d::Node::stopAction(Action * action)
|
||||
{
|
||||
if (action->getTarget() == this)
|
||||
{
|
||||
|
|
@ -807,29 +807,29 @@ void e2d::ENode::stopAction(EAction * action)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::resumeAllActions()
|
||||
void e2d::Node::resumeAllActions()
|
||||
{
|
||||
EActionManager::resumeAllActionsBindedWith(this);
|
||||
ActionManager::resumeAllActionsBindedWith(this);
|
||||
}
|
||||
|
||||
void e2d::ENode::pauseAllActions()
|
||||
void e2d::Node::pauseAllActions()
|
||||
{
|
||||
EActionManager::pauseAllActionsBindedWith(this);
|
||||
ActionManager::pauseAllActionsBindedWith(this);
|
||||
}
|
||||
|
||||
void e2d::ENode::stopAllActions()
|
||||
void e2d::Node::stopAllActions()
|
||||
{
|
||||
EActionManager::stopAllActionsBindedWith(this);
|
||||
ActionManager::stopAllActionsBindedWith(this);
|
||||
}
|
||||
|
||||
void e2d::ENode::setVisiable(bool value)
|
||||
void e2d::Node::setVisiable(bool value)
|
||||
{
|
||||
m_bVisiable = value;
|
||||
}
|
||||
|
||||
void e2d::ENode::setName(const EString & name)
|
||||
void e2d::Node::setName(const String & name)
|
||||
{
|
||||
WARN_IF(name.isEmpty(), "Invalid ENode name.");
|
||||
WARN_IF(name.isEmpty(), "Invalid Node name.");
|
||||
|
||||
if (!name.isEmpty() && m_sName != name)
|
||||
{
|
||||
|
|
@ -840,7 +840,7 @@ void e2d::ENode::setName(const EString & name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ENode::_setParentScene(EScene * scene)
|
||||
void e2d::Node::_setParentScene(Scene * scene)
|
||||
{
|
||||
m_pParentScene = scene;
|
||||
for (auto child : m_vChildren)
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
#include "..\enodes.h"
|
||||
|
||||
|
||||
e2d::ESprite::ESprite()
|
||||
e2d::Sprite::Sprite()
|
||||
: m_pImage(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ESprite::ESprite(EImage * image)
|
||||
e2d::Sprite::Sprite(Image * image)
|
||||
: m_pImage(nullptr)
|
||||
{
|
||||
loadFrom(image);
|
||||
}
|
||||
|
||||
e2d::ESprite::ESprite(LPCTSTR imageFileName)
|
||||
e2d::Sprite::Sprite(LPCTSTR imageFileName)
|
||||
: m_pImage(nullptr)
|
||||
{
|
||||
loadFrom(imageFileName);
|
||||
}
|
||||
|
||||
e2d::ESprite::ESprite(LPCTSTR imageFileName, float x, float y, float width, float height)
|
||||
e2d::Sprite::Sprite(LPCTSTR imageFileName, float x, float y, float width, float height)
|
||||
: m_pImage(nullptr)
|
||||
{
|
||||
loadFrom(imageFileName);
|
||||
clip(x, y, width, height);
|
||||
}
|
||||
|
||||
e2d::ESprite::~ESprite()
|
||||
e2d::Sprite::~Sprite()
|
||||
{
|
||||
SafeRelease(&m_pImage);
|
||||
}
|
||||
|
||||
void e2d::ESprite::loadFrom(EImage * image)
|
||||
void e2d::Sprite::loadFrom(Image * image)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
|
|
@ -38,35 +38,35 @@ void e2d::ESprite::loadFrom(EImage * image)
|
|||
m_pImage = image;
|
||||
m_pImage->retain();
|
||||
|
||||
ENode::_setSize(m_pImage->getWidth(), m_pImage->getHeight());
|
||||
Node::_setSize(m_pImage->getWidth(), m_pImage->getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::ESprite::loadFrom(LPCTSTR imageFileName)
|
||||
void e2d::Sprite::loadFrom(LPCTSTR imageFileName)
|
||||
{
|
||||
loadFrom(new EImage(imageFileName));
|
||||
loadFrom(new Image(imageFileName));
|
||||
}
|
||||
|
||||
void e2d::ESprite::clip(float x, float y, float width, float height)
|
||||
void e2d::Sprite::clip(float x, float y, float width, float height)
|
||||
{
|
||||
m_pImage->clip(x, y, width, height);
|
||||
ENode::_setSize(
|
||||
Node::_setSize(
|
||||
min(max(width, 0), m_pImage->getSourceWidth() - m_pImage->getClipX()),
|
||||
min(max(height, 0), m_pImage->getSourceHeight() - m_pImage->getClipY())
|
||||
);
|
||||
}
|
||||
|
||||
e2d::EImage * e2d::ESprite::getImage() const
|
||||
e2d::Image * e2d::Sprite::getImage() const
|
||||
{
|
||||
return m_pImage;
|
||||
}
|
||||
|
||||
void e2d::ESprite::onRender()
|
||||
void e2d::Sprite::onRender()
|
||||
{
|
||||
if (m_pImage && m_pImage->getBitmap())
|
||||
{
|
||||
// äÖȾͼƬ
|
||||
ERenderer::getRenderTarget()->DrawBitmap(
|
||||
Renderer::getRenderTarget()->DrawBitmap(
|
||||
m_pImage->getBitmap(),
|
||||
D2D1::RectF(0, 0, getRealWidth(), getRealHeight()),
|
||||
m_fDisplayOpacity,
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
#include "..\enodes.h"
|
||||
|
||||
e2d::EText::EText()
|
||||
e2d::Text::Text()
|
||||
: m_bWordWrapping(false)
|
||||
, m_pFont(nullptr)
|
||||
, m_fWordWrappingWidth(0)
|
||||
{
|
||||
this->setFont(new EFont());
|
||||
this->setFont(new Font());
|
||||
}
|
||||
|
||||
e2d::EText::EText(const EString & text)
|
||||
e2d::Text::Text(const String & text)
|
||||
: m_bWordWrapping(false)
|
||||
, m_pFont(nullptr)
|
||||
, m_fWordWrappingWidth(0)
|
||||
{
|
||||
this->setText(text);
|
||||
this->setFont(new EFont());
|
||||
this->setFont(new Font());
|
||||
}
|
||||
|
||||
e2d::EText::EText(EFont * font)
|
||||
e2d::Text::Text(Font * font)
|
||||
: m_bWordWrapping(false)
|
||||
, m_pFont(nullptr)
|
||||
, m_fWordWrappingWidth(0)
|
||||
|
|
@ -25,7 +25,7 @@ e2d::EText::EText(EFont * font)
|
|||
this->setFont(font);
|
||||
}
|
||||
|
||||
e2d::EText::EText(const EString & text, EFont * font)
|
||||
e2d::Text::Text(const String & text, Font * font)
|
||||
: m_bWordWrapping(false)
|
||||
, m_pFont(nullptr)
|
||||
, m_fWordWrappingWidth(0)
|
||||
|
|
@ -34,47 +34,47 @@ e2d::EText::EText(const EString & text, EFont * font)
|
|||
this->setFont(font);
|
||||
}
|
||||
|
||||
e2d::EText::EText(const EString & text, EString fontFamily, float fontSize, UINT32 color, UINT32 fontWeight, bool italic)
|
||||
e2d::Text::Text(const String & text, String fontFamily, float fontSize, UINT32 color, UINT32 fontWeight, bool italic)
|
||||
: m_bWordWrapping(false)
|
||||
, m_pFont(nullptr)
|
||||
, m_fWordWrappingWidth(0)
|
||||
{
|
||||
this->setText(text);
|
||||
this->setFont(new EFont(fontFamily, fontSize, color, fontWeight, italic));
|
||||
this->setFont(new Font(fontFamily, fontSize, color, fontWeight, italic));
|
||||
}
|
||||
|
||||
e2d::EText::~EText()
|
||||
e2d::Text::~Text()
|
||||
{
|
||||
SafeRelease(&m_pFont);
|
||||
}
|
||||
|
||||
e2d::EString e2d::EText::getText() const
|
||||
e2d::String e2d::Text::getText() const
|
||||
{
|
||||
return m_sText;
|
||||
}
|
||||
|
||||
float e2d::EText::getWidth() const
|
||||
float e2d::Text::getWidth() const
|
||||
{
|
||||
return m_fWordWrappingWidth * m_fScaleX;
|
||||
}
|
||||
|
||||
float e2d::EText::getRealWidth() const
|
||||
float e2d::Text::getRealWidth() const
|
||||
{
|
||||
return m_fWordWrappingWidth;
|
||||
}
|
||||
|
||||
e2d::EFont * e2d::EText::getFont() const
|
||||
e2d::Font * e2d::Text::getFont() const
|
||||
{
|
||||
return m_pFont;
|
||||
}
|
||||
|
||||
void e2d::EText::setText(const EString & text)
|
||||
void e2d::Text::setText(const String & text)
|
||||
{
|
||||
m_sText = text;
|
||||
_initTextLayout();
|
||||
}
|
||||
|
||||
void e2d::EText::setFont(EFont * font)
|
||||
void e2d::Text::setFont(Font * font)
|
||||
{
|
||||
if (font)
|
||||
{
|
||||
|
|
@ -86,22 +86,22 @@ void e2d::EText::setFont(EFont * font)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::EText::setWordWrapping(bool value)
|
||||
void e2d::Text::setWordWrapping(bool value)
|
||||
{
|
||||
m_bWordWrapping = value;
|
||||
_initTextLayout();
|
||||
}
|
||||
|
||||
void e2d::EText::setWordWrappingWidth(float wordWrapWidth)
|
||||
void e2d::Text::setWordWrappingWidth(float wordWrapWidth)
|
||||
{
|
||||
m_fWordWrappingWidth = max(wordWrapWidth, 0);
|
||||
_initTextLayout();
|
||||
}
|
||||
|
||||
void e2d::EText::onRender()
|
||||
void e2d::Text::onRender()
|
||||
{
|
||||
ERenderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_pFont->m_Color, m_fDisplayOpacity));
|
||||
ERenderer::getRenderTarget()->DrawTextW(
|
||||
Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_pFont->m_Color, m_fDisplayOpacity));
|
||||
Renderer::getRenderTarget()->DrawTextW(
|
||||
m_sText,
|
||||
UINT32(m_sText.length()),
|
||||
m_pFont->_getTextFormat(),
|
||||
|
|
@ -111,11 +111,11 @@ void e2d::EText::onRender()
|
|||
m_bWordWrapping ? m_fWordWrappingWidth : m_Size.width,
|
||||
getRealHeight()
|
||||
),
|
||||
ERenderer::getSolidColorBrush()
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::EText::_initTextLayout()
|
||||
void e2d::Text::_initTextLayout()
|
||||
{
|
||||
// 未设置字体或空字符串时,文本宽高为 0
|
||||
if (!m_pFont || m_sText.isEmpty())
|
||||
|
|
@ -138,7 +138,7 @@ void e2d::EText::_initTextLayout()
|
|||
// 获取 TextLayout
|
||||
IDWriteTextLayout * pDWriteTextLayout = nullptr;
|
||||
|
||||
HRESULT hr = ERenderer::getIDWriteFactory()->CreateTextLayout(
|
||||
HRESULT hr = Renderer::getIDWriteFactory()->CreateTextLayout(
|
||||
m_sText,
|
||||
UINT32(m_sText.length()),
|
||||
m_pFont->_getTextFormat(),
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ECircle::ECircle()
|
||||
e2d::Circle::Circle()
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ECircle::ECircle(EPoint center, float radius)
|
||||
e2d::Circle::Circle(Point center, float radius)
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
this->_setCircle(center, radius);
|
||||
}
|
||||
|
||||
e2d::ECircle::ECircle(ENode * node)
|
||||
e2d::Circle::Circle(Node * node)
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
float minSide = min(node->getRealWidth(), node->getRealHeight());
|
||||
this->_setCircle(
|
||||
EPoint(
|
||||
Point(
|
||||
node->getRealWidth() / 2,
|
||||
node->getRealHeight() / 2
|
||||
),
|
||||
|
|
@ -25,16 +25,16 @@ e2d::ECircle::ECircle(ENode * node)
|
|||
);
|
||||
}
|
||||
|
||||
e2d::ECircle::~ECircle()
|
||||
e2d::Circle::~Circle()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
}
|
||||
|
||||
void e2d::ECircle::_setCircle(EPoint center, float radius)
|
||||
void e2d::Circle::_setCircle(Point center, float radius)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
|
||||
ERenderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
Renderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
D2D1::Point2F(
|
||||
center.x,
|
||||
|
|
@ -45,7 +45,7 @@ void e2d::ECircle::_setCircle(EPoint center, float radius)
|
|||
);
|
||||
}
|
||||
|
||||
ID2D1EllipseGeometry * e2d::ECircle::_getD2dGeometry() const
|
||||
ID2D1EllipseGeometry * e2d::Circle::_getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dCircle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::EEllipse::EEllipse()
|
||||
e2d::Ellipse::Ellipse()
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EEllipse::EEllipse(EPoint center, float radiusX, float radiusY)
|
||||
e2d::Ellipse::Ellipse(Point center, float radiusX, float radiusY)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
this->_setEllipse(center, radiusX, radiusY);
|
||||
}
|
||||
|
||||
e2d::EEllipse::EEllipse(ENode * node)
|
||||
e2d::Ellipse::Ellipse(Node * node)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
this->_setEllipse(
|
||||
EPoint(
|
||||
Point(
|
||||
node->getWidth() / 2,
|
||||
node->getHeight() / 2
|
||||
),
|
||||
|
|
@ -25,16 +25,16 @@ e2d::EEllipse::EEllipse(ENode * node)
|
|||
);
|
||||
}
|
||||
|
||||
e2d::EEllipse::~EEllipse()
|
||||
e2d::Ellipse::~Ellipse()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
}
|
||||
|
||||
void e2d::EEllipse::_setEllipse(EPoint center, float radiusX, float radiusY)
|
||||
void e2d::Ellipse::_setEllipse(Point center, float radiusX, float radiusY)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
|
||||
ERenderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
Renderer::getID2D1Factory()->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
D2D1::Point2F(
|
||||
center.x,
|
||||
|
|
@ -45,7 +45,7 @@ void e2d::EEllipse::_setEllipse(EPoint center, float radiusX, float radiusY)
|
|||
);
|
||||
}
|
||||
|
||||
ID2D1EllipseGeometry * e2d::EEllipse::_getD2dGeometry() const
|
||||
ID2D1EllipseGeometry * e2d::Ellipse::_getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dEllipse;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ERectangle::ERectangle()
|
||||
e2d::Rect::Rect()
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ERectangle::ERectangle(float x, float y, float width, float height)
|
||||
e2d::Rect::Rect(float x, float y, float width, float height)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->_setRect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
e2d::ERectangle::ERectangle(ENode * node)
|
||||
e2d::Rect::Rect(Node * node)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->_setRect(
|
||||
|
|
@ -23,22 +23,22 @@ e2d::ERectangle::ERectangle(ENode * node)
|
|||
);
|
||||
}
|
||||
|
||||
e2d::ERectangle::~ERectangle()
|
||||
e2d::Rect::~Rect()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
}
|
||||
|
||||
void e2d::ERectangle::_setRect(float left, float top, float right, float bottom)
|
||||
void e2d::Rect::_setRect(float left, float top, float right, float bottom)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
|
||||
ERenderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(left, top, right, bottom),
|
||||
&m_pD2dRectangle
|
||||
);
|
||||
}
|
||||
|
||||
ID2D1RectangleGeometry * e2d::ERectangle::_getD2dGeometry() const
|
||||
ID2D1RectangleGeometry * e2d::Rect::_getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dRectangle;
|
||||
}
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::EShape::EShape()
|
||||
e2d::Shape::Shape()
|
||||
: m_nCategoryBitmask(0)
|
||||
, m_nCollisionBitmask(0)
|
||||
, m_bIsVisiable(true)
|
||||
, m_nColor(EColor::RED)
|
||||
, m_nColor(Color::RED)
|
||||
, m_fOpacity(1)
|
||||
, m_pParentNode(nullptr)
|
||||
, m_pTransformedShape(nullptr)
|
||||
|
|
@ -14,74 +14,74 @@ e2d::EShape::EShape()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::EShape::~EShape()
|
||||
e2d::Shape::~Shape()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTransformedShape);
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::EShape::getParentNode() const
|
||||
e2d::Node * e2d::Shape::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
}
|
||||
|
||||
UINT32 e2d::EShape::getCategoryBitmask() const
|
||||
UINT32 e2d::Shape::getCategoryBitmask() const
|
||||
{
|
||||
return m_nCategoryBitmask;
|
||||
}
|
||||
|
||||
UINT32 e2d::EShape::getCollisionBitmask() const
|
||||
UINT32 e2d::Shape::getCollisionBitmask() const
|
||||
{
|
||||
return m_nCollisionBitmask;
|
||||
}
|
||||
|
||||
void e2d::EShape::setCategoryBitmask(UINT32 mask)
|
||||
void e2d::Shape::setCategoryBitmask(UINT32 mask)
|
||||
{
|
||||
m_nCategoryBitmask = mask;
|
||||
}
|
||||
|
||||
void e2d::EShape::setCollisionBitmask(UINT32 mask)
|
||||
void e2d::Shape::setCollisionBitmask(UINT32 mask)
|
||||
{
|
||||
m_nCollisionBitmask = mask;
|
||||
}
|
||||
|
||||
void e2d::EShape::setEnable(bool bEnable)
|
||||
void e2d::Shape::setEnable(bool bEnable)
|
||||
{
|
||||
m_bEnable = bEnable;
|
||||
}
|
||||
|
||||
void e2d::EShape::setVisiable(bool bVisiable)
|
||||
void e2d::Shape::setVisiable(bool bVisiable)
|
||||
{
|
||||
m_bIsVisiable = bVisiable;
|
||||
}
|
||||
|
||||
void e2d::EShape::setColor(UINT32 color)
|
||||
void e2d::Shape::setColor(UINT32 color)
|
||||
{
|
||||
m_nColor = color;
|
||||
}
|
||||
|
||||
void e2d::EShape::setOpacity(float opacity)
|
||||
void e2d::Shape::setOpacity(float opacity)
|
||||
{
|
||||
m_fOpacity = min(max(opacity, 0), 1);
|
||||
}
|
||||
|
||||
void e2d::EShape::_render()
|
||||
void e2d::Shape::_render()
|
||||
{
|
||||
if (m_pTransformedShape && m_bEnable)
|
||||
{
|
||||
ID2D1SolidColorBrush * pBrush = ERenderer::getSolidColorBrush();
|
||||
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush();
|
||||
// 눼쉔뺌岬
|
||||
ERenderer::getRenderTarget()->CreateSolidColorBrush(
|
||||
Renderer::getRenderTarget()->CreateSolidColorBrush(
|
||||
D2D1::ColorF(
|
||||
m_nColor,
|
||||
m_fOpacity),
|
||||
&pBrush
|
||||
);
|
||||
// 삥齡섯부近榴
|
||||
ERenderer::getRenderTarget()->DrawGeometry(m_pTransformedShape, pBrush);
|
||||
Renderer::getRenderTarget()->DrawGeometry(m_pTransformedShape, pBrush);
|
||||
}
|
||||
}
|
||||
|
||||
int e2d::EShape::getRelationWith(EShape * pShape) const
|
||||
int e2d::Shape::getRelationWith(Shape * pShape) const
|
||||
{
|
||||
if (m_pTransformedShape && pShape->m_pTransformedShape)
|
||||
{
|
||||
|
|
@ -101,7 +101,7 @@ int e2d::EShape::getRelationWith(EShape * pShape) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
void e2d::EShape::_transform()
|
||||
void e2d::Shape::_transform()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
|
|
@ -109,12 +109,12 @@ void e2d::EShape::_transform()
|
|||
SafeReleaseInterface(&m_pTransformedShape);
|
||||
|
||||
// 몽앴만쌘듐瘻뻣섯부暠近
|
||||
ERenderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
_getD2dGeometry(),
|
||||
m_pParentNode->m_MatriFinal,
|
||||
&m_pTransformedShape
|
||||
);
|
||||
|
||||
EShapeManager::__updateShape(this);
|
||||
ShapeManager::__updateShape(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
#include "..\etools.h"
|
||||
|
||||
|
||||
void e2d::EData::saveInt(const EString & key, int value)
|
||||
void e2d::Data::saveInt(const String & key, int value)
|
||||
{
|
||||
::WritePrivateProfileString(L"Default", key, EString::parse(value), EFile::getDefaultSavePath());
|
||||
::WritePrivateProfileString(L"Default", key, String::parse(value), File::getDefaultSavePath());
|
||||
}
|
||||
|
||||
void e2d::EData::saveFloat(const EString & key, float value)
|
||||
void e2d::Data::saveFloat(const String & key, float value)
|
||||
{
|
||||
::WritePrivateProfileString(L"Default", key, EString::parse(value), EFile::getDefaultSavePath());
|
||||
::WritePrivateProfileString(L"Default", key, String::parse(value), File::getDefaultSavePath());
|
||||
}
|
||||
|
||||
void e2d::EData::saveString(const EString & key, const EString & value)
|
||||
void e2d::Data::saveString(const String & key, const String & value)
|
||||
{
|
||||
::WritePrivateProfileString(L"Default", key, value, EFile::getDefaultSavePath());
|
||||
::WritePrivateProfileString(L"Default", key, value, File::getDefaultSavePath());
|
||||
}
|
||||
|
||||
int e2d::EData::getInt(const EString & key, int default)
|
||||
int e2d::Data::getInt(const String & key, int default)
|
||||
{
|
||||
return ::GetPrivateProfileInt(L"Default", key, default, EFile::getDefaultSavePath());
|
||||
return ::GetPrivateProfileInt(L"Default", key, default, File::getDefaultSavePath());
|
||||
}
|
||||
|
||||
float e2d::EData::getFloat(const EString & key, float default)
|
||||
float e2d::Data::getFloat(const String & key, float default)
|
||||
{
|
||||
wchar_t temp[32] = { 0 };
|
||||
::GetPrivateProfileString(L"Default", key, EString::parse(default), temp, 31, EFile::getDefaultSavePath());
|
||||
::GetPrivateProfileString(L"Default", key, String::parse(default), temp, 31, File::getDefaultSavePath());
|
||||
return std::stof(temp);
|
||||
}
|
||||
|
||||
e2d::EString e2d::EData::getString(const EString & key, const EString & default)
|
||||
e2d::String e2d::Data::getString(const String & key, const String & default)
|
||||
{
|
||||
wchar_t temp[256] = { 0 };
|
||||
::GetPrivateProfileString(L"Default", key, default, temp, 255, EFile::getDefaultSavePath());
|
||||
::GetPrivateProfileString(L"Default", key, default, temp, 255, File::getDefaultSavePath());
|
||||
return temp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
DEFINE_KNOWN_FOLDER(FOLDERID_LocalAppData, 0xF1B32785, 0x6FBA, 0x4FCF, 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91);
|
||||
|
||||
|
||||
e2d::EString e2d::EFile::getLocalAppDataPath()
|
||||
e2d::String e2d::File::getLocalAppDataPath()
|
||||
{
|
||||
typedef HRESULT(WINAPI* pFunSHGetKnownFolderPath)(const GUID& rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
|
||||
|
||||
|
|
@ -21,21 +21,21 @@ e2d::EString e2d::EFile::getLocalAppDataPath()
|
|||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
EString path = pszPath;
|
||||
String path = pszPath;
|
||||
CoTaskMemFree(pszPath);
|
||||
return path;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
e2d::EString e2d::EFile::getTempPath()
|
||||
e2d::String e2d::File::getTempPath()
|
||||
{
|
||||
// 获取临时文件目录
|
||||
wchar_t path[_MAX_PATH];
|
||||
::GetTempPath(_MAX_PATH, path);
|
||||
|
||||
// 创建临时文件目录
|
||||
e2d::EString tempFilePath = path + e2d::EGame::getAppName();
|
||||
e2d::String tempFilePath = path + e2d::Game::getAppName();
|
||||
if (::_waccess(tempFilePath, 0) == -1)
|
||||
{
|
||||
::_wmkdir(tempFilePath);
|
||||
|
|
@ -43,12 +43,12 @@ e2d::EString e2d::EFile::getTempPath()
|
|||
return tempFilePath;
|
||||
}
|
||||
|
||||
e2d::EString e2d::EFile::getDefaultSavePath()
|
||||
e2d::String e2d::File::getDefaultSavePath()
|
||||
{
|
||||
EString path = EFile::getLocalAppDataPath();
|
||||
String path = File::getLocalAppDataPath();
|
||||
WARN_IF(path.isEmpty(), "Cannot get local AppData path!");
|
||||
|
||||
path += L"\\" + EGame::getAppName();
|
||||
path += L"\\" + Game::getAppName();
|
||||
|
||||
if (::_waccess(path, 0) == -1)
|
||||
{
|
||||
|
|
@ -60,9 +60,9 @@ e2d::EString e2d::EFile::getDefaultSavePath()
|
|||
return path;
|
||||
}
|
||||
|
||||
e2d::EString e2d::EFile::getFileExtension(const EString & filePath)
|
||||
e2d::String e2d::File::getFileExtension(const String & filePath)
|
||||
{
|
||||
EString fileExtension;
|
||||
String fileExtension;
|
||||
// 找到文件名中的最后一个 '.' 的位置
|
||||
int pos = filePath.findLastOf(L'.');
|
||||
// 判断 pos 是否是个有效位置
|
||||
|
|
@ -77,13 +77,13 @@ e2d::EString e2d::EFile::getFileExtension(const EString & filePath)
|
|||
return fileExtension;
|
||||
}
|
||||
|
||||
e2d::EString e2d::EFile::getSaveFilePath(const EString & title, const EString & defExt)
|
||||
e2d::String e2d::File::getSaveFilePath(const String & title, const String & defExt)
|
||||
{
|
||||
// 弹出保存对话框
|
||||
OPENFILENAME ofn = { 0 };
|
||||
TCHAR strFilename[MAX_PATH] = { 0 }; // 用于接收文件名
|
||||
ofn.lStructSize = sizeof(OPENFILENAME); // 结构体大小
|
||||
ofn.hwndOwner = EWindow::getHWnd(); // ´°¿Ú¾ä±ú
|
||||
ofn.hwndOwner = Window::getHWnd(); // ´°¿Ú¾ä±ú
|
||||
ofn.lpstrFilter = L"所有文件\0*.*\0\0"; // 设置过滤
|
||||
ofn.nFilterIndex = 1; // 过滤器索引
|
||||
ofn.lpstrFile = strFilename; // 接收返回的文件路径和文件名
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ using namespace e2d;
|
|||
|
||||
inline bool TraceError(LPCTSTR sPrompt)
|
||||
{
|
||||
WARN_IF(true, "EMusic error: %s failed!", sPrompt);
|
||||
WARN_IF(true, "Music error: %s failed!", sPrompt);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool TraceError(LPCTSTR sPrompt, HRESULT hr)
|
||||
{
|
||||
WARN_IF(true, "EMusic error: %s (%#X)", sPrompt, hr);
|
||||
WARN_IF(true, "Music error: %s (%#X)", sPrompt, hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
EMusic::EMusic()
|
||||
Music::Music()
|
||||
: m_bOpened(false)
|
||||
, m_bPlaying(false)
|
||||
, m_pwfx(nullptr)
|
||||
|
|
@ -35,26 +35,26 @@ EMusic::EMusic()
|
|||
{
|
||||
}
|
||||
|
||||
EMusic::~EMusic()
|
||||
Music::~Music()
|
||||
{
|
||||
_close();
|
||||
}
|
||||
|
||||
bool EMusic::_open(LPWSTR strFileName)
|
||||
bool Music::_open(LPWSTR strFileName)
|
||||
{
|
||||
if (m_bOpened)
|
||||
{
|
||||
WARN_IF(true, L"EMusic can be opened only once!");
|
||||
WARN_IF(true, L"Music can be opened only once!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strFileName == nullptr)
|
||||
{
|
||||
WARN_IF(true, L"EMusic::_open Invalid file name.");
|
||||
WARN_IF(true, L"Music::_open Invalid file name.");
|
||||
return false;
|
||||
}
|
||||
|
||||
IXAudio2 * pXAudio2 = EMusicManager::getIXAudio2();
|
||||
IXAudio2 * pXAudio2 = MusicManager::getIXAudio2();
|
||||
if (!pXAudio2)
|
||||
{
|
||||
WARN_IF(true, L"IXAudio2 nullptr pointer error!");
|
||||
|
|
@ -113,7 +113,7 @@ bool EMusic::_open(LPWSTR strFileName)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EMusic::play(int nLoopCount)
|
||||
bool Music::play(int nLoopCount)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ bool EMusic::play(int nLoopCount)
|
|||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
bool EMusic::pause()
|
||||
bool Music::pause()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@ bool EMusic::pause()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EMusic::resume()
|
||||
bool Music::resume()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -174,7 +174,7 @@ bool EMusic::resume()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EMusic::stop()
|
||||
bool Music::stop()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -189,7 +189,7 @@ bool EMusic::stop()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EMusic::isPlaying()
|
||||
bool Music::isPlaying()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -208,7 +208,7 @@ bool EMusic::isPlaying()
|
|||
}
|
||||
}
|
||||
|
||||
float EMusic::getVolume() const
|
||||
float Music::getVolume() const
|
||||
{
|
||||
float fVolume = 0.0f;
|
||||
if (m_pSourceVoice)
|
||||
|
|
@ -218,7 +218,7 @@ float EMusic::getVolume() const
|
|||
return fVolume;
|
||||
}
|
||||
|
||||
bool EMusic::setVolume(float fVolume)
|
||||
bool Music::setVolume(float fVolume)
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ bool EMusic::setVolume(float fVolume)
|
|||
return false;
|
||||
}
|
||||
|
||||
float EMusic::getFrequencyRatio() const
|
||||
float Music::getFrequencyRatio() const
|
||||
{
|
||||
float fFrequencyRatio = 0.0f;
|
||||
if (m_pSourceVoice)
|
||||
|
|
@ -237,7 +237,7 @@ float EMusic::getFrequencyRatio() const
|
|||
return fFrequencyRatio;
|
||||
}
|
||||
|
||||
bool EMusic::setFrequencyRatio(float fFrequencyRatio)
|
||||
bool Music::setFrequencyRatio(float fFrequencyRatio)
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -247,12 +247,12 @@ bool EMusic::setFrequencyRatio(float fFrequencyRatio)
|
|||
return false;
|
||||
}
|
||||
|
||||
IXAudio2SourceVoice * EMusic::getIXAudio2SourceVoice() const
|
||||
IXAudio2SourceVoice * Music::getIXAudio2SourceVoice() const
|
||||
{
|
||||
return m_pSourceVoice;
|
||||
}
|
||||
|
||||
void EMusic::_close()
|
||||
void Music::_close()
|
||||
{
|
||||
if (m_pSourceVoice)
|
||||
{
|
||||
|
|
@ -276,7 +276,7 @@ void EMusic::_close()
|
|||
m_bPlaying = false;
|
||||
}
|
||||
|
||||
bool EMusic::_readMMIO()
|
||||
bool Music::_readMMIO()
|
||||
{
|
||||
MMCKINFO ckIn;
|
||||
PCMWAVEFORMAT pcmWaveFormat;
|
||||
|
|
@ -348,7 +348,7 @@ bool EMusic::_readMMIO()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EMusic::_resetFile()
|
||||
bool Music::_resetFile()
|
||||
{
|
||||
// Seek to the data
|
||||
if (-1 == mmioSeek(m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC),
|
||||
|
|
@ -363,7 +363,7 @@ bool EMusic::_resetFile()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EMusic::_read(BYTE* pBuffer, DWORD dwSizeToRead)
|
||||
bool Music::_read(BYTE* pBuffer, DWORD dwSizeToRead)
|
||||
{
|
||||
MMIOINFO mmioinfoIn; // current status of m_hmmio
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ bool EMusic::_read(BYTE* pBuffer, DWORD dwSizeToRead)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EMusic::_findMediaFileCch(WCHAR* strDestPath, int cchDest, LPCWSTR strFilename)
|
||||
bool Music::_findMediaFileCch(WCHAR* strDestPath, int cchDest, LPCWSTR strFilename)
|
||||
{
|
||||
bool bFound = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\etools.h"
|
||||
|
||||
std::default_random_engine &e2d::ERandom::getEngine()
|
||||
std::default_random_engine &e2d::Random::getEngine()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::default_random_engine engine(device());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
|
||||
e2d::ETimer::ETimer()
|
||||
e2d::Timer::Timer()
|
||||
: m_bRunning(false)
|
||||
, m_nRunTimes(0)
|
||||
, m_pParentNode(nullptr)
|
||||
|
|
@ -14,7 +14,7 @@ e2d::ETimer::ETimer()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::ETimer::ETimer(const TimerCallback & callback, int repeatTimes /* = -1 */, float interval /* = 0 */, bool atOnce /* = false */)
|
||||
e2d::Timer::Timer(const TimerCallback & callback, float interval /* = 0 */, int repeatTimes /* = -1 */, bool atOnce /* = false */)
|
||||
: m_bRunning(false)
|
||||
, m_nRunTimes(0)
|
||||
, m_pParentNode(nullptr)
|
||||
|
|
@ -30,7 +30,7 @@ e2d::ETimer::ETimer(const TimerCallback & callback, int repeatTimes /* = -1 */,
|
|||
m_bAtOnce = atOnce;
|
||||
}
|
||||
|
||||
e2d::ETimer::ETimer(const EString & name, const TimerCallback & callback, int repeatTimes /* = -1 */, float interval /* = 0 */, bool atOnce /* = false */)
|
||||
e2d::Timer::Timer(const String & name, const TimerCallback & callback, float interval /* = 0 */, int repeatTimes /* = -1 */, bool atOnce /* = false */)
|
||||
: m_bRunning(false)
|
||||
, m_nRunTimes(0)
|
||||
, m_pParentNode(nullptr)
|
||||
|
|
@ -47,87 +47,78 @@ e2d::ETimer::ETimer(const EString & name, const TimerCallback & callback, int re
|
|||
m_bAtOnce = atOnce;
|
||||
}
|
||||
|
||||
bool e2d::ETimer::isRunning() const
|
||||
bool e2d::Timer::isRunning() const
|
||||
{
|
||||
return m_bRunning;
|
||||
}
|
||||
|
||||
void e2d::ETimer::start()
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_fLast = ETime::getTotalTime();
|
||||
}
|
||||
|
||||
void e2d::ETimer::stop()
|
||||
void e2d::Timer::stop()
|
||||
{
|
||||
m_bRunning = false;
|
||||
}
|
||||
|
||||
e2d::EString e2d::ETimer::getName() const
|
||||
void e2d::Timer::start()
|
||||
{
|
||||
m_bRunning = true;
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
|
||||
e2d::String e2d::Timer::getName() const
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::ETimer::getParentNode() const
|
||||
e2d::Node * e2d::Timer::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
}
|
||||
|
||||
void e2d::ETimer::setName(const EString & name)
|
||||
void e2d::Timer::setName(const String & name)
|
||||
{
|
||||
m_sName = name;
|
||||
}
|
||||
|
||||
void e2d::ETimer::setInterval(float interval)
|
||||
void e2d::Timer::setInterval(float interval)
|
||||
{
|
||||
m_fInterval = max(interval, 0);
|
||||
}
|
||||
|
||||
void e2d::ETimer::setCallback(const TimerCallback & callback)
|
||||
void e2d::Timer::setCallback(const TimerCallback & callback)
|
||||
{
|
||||
m_Callback = callback;
|
||||
}
|
||||
|
||||
void e2d::ETimer::setRepeatTimes(int repeatTimes)
|
||||
void e2d::Timer::setRepeatTimes(int repeatTimes)
|
||||
{
|
||||
m_nRepeatTimes = repeatTimes;
|
||||
}
|
||||
|
||||
void e2d::ETimer::setRunAtOnce(bool bAtOnce)
|
||||
void e2d::Timer::setRunAtOnce(bool bAtOnce)
|
||||
{
|
||||
m_bAtOnce = bAtOnce;
|
||||
}
|
||||
|
||||
void e2d::ETimer::bindWith(EScene * pParentScene)
|
||||
void e2d::Timer::_callOn()
|
||||
{
|
||||
ETimerManager::bindTimer(this, pParentScene);
|
||||
}
|
||||
if (m_Callback)
|
||||
{
|
||||
m_Callback();
|
||||
}
|
||||
|
||||
void e2d::ETimer::bindWith(ENode * pParentNode)
|
||||
{
|
||||
ETimerManager::bindTimer(this, pParentNode);
|
||||
}
|
||||
m_nRunTimes++;
|
||||
m_fLast += m_fInterval;
|
||||
|
||||
void e2d::ETimer::_callOn()
|
||||
{
|
||||
if (m_nRunTimes == m_nRepeatTimes)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Callback)
|
||||
{
|
||||
m_Callback(m_nRunTimes);
|
||||
}
|
||||
m_nRunTimes++;
|
||||
}
|
||||
|
||||
bool e2d::ETimer::_isReady()
|
||||
bool e2d::Timer::_isReady() const
|
||||
{
|
||||
if (m_bRunning &&
|
||||
m_pParentNode &&
|
||||
m_pParentNode->getParentScene() == ESceneManager::getCurrentScene())
|
||||
m_pParentNode->getParentScene() == SceneManager::getCurrentScene())
|
||||
{
|
||||
if (m_bAtOnce && m_nRunTimes == 0)
|
||||
return true;
|
||||
|
|
@ -135,9 +126,8 @@ bool e2d::ETimer::_isReady()
|
|||
if (m_fInterval == 0)
|
||||
return true;
|
||||
|
||||
if ((ETime::getTotalTime() - m_fLast) >= m_fInterval)
|
||||
if ((Time::getTotalTime() - m_fLast) >= m_fInterval)
|
||||
{
|
||||
m_fLast += m_fInterval;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\etransitions.h"
|
||||
|
||||
e2d::ETransition::ETransition(float duration)
|
||||
e2d::Transition::Transition(float duration)
|
||||
: m_bEnd(false)
|
||||
, m_fLast(0)
|
||||
, m_fRateOfProgress(0)
|
||||
|
|
@ -11,12 +11,12 @@ e2d::ETransition::ETransition(float duration)
|
|||
m_fDuration = max(duration, 0);
|
||||
}
|
||||
|
||||
bool e2d::ETransition::isEnding()
|
||||
bool e2d::Transition::isEnding()
|
||||
{
|
||||
return m_bEnd;
|
||||
}
|
||||
|
||||
void e2d::ETransition::_calcRateOfProgress()
|
||||
void e2d::Transition::_calcRateOfProgress()
|
||||
{
|
||||
// 判断时间间隔是否足够
|
||||
if (m_fDuration == 0)
|
||||
|
|
@ -26,18 +26,18 @@ void e2d::ETransition::_calcRateOfProgress()
|
|||
}
|
||||
|
||||
// 计算动画进度
|
||||
m_fRateOfProgress = min((ETime::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
m_fRateOfProgress = min((Time::getTotalTime() - m_fLast) / m_fDuration, 1);
|
||||
}
|
||||
|
||||
void e2d::ETransition::_stop()
|
||||
void e2d::Transition::_stop()
|
||||
{
|
||||
m_bEnd = true;
|
||||
_reset();
|
||||
}
|
||||
|
||||
void e2d::ETransition::_setTarget(EScene * prev, EScene * next)
|
||||
void e2d::Transition::_setTarget(Scene * prev, Scene * next)
|
||||
{
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
m_pPrevScene = prev;
|
||||
m_pNextScene = next;
|
||||
_init();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ETransitionEmerge::ETransitionEmerge(float duration)
|
||||
: ETransition(duration)
|
||||
e2d::TransitionEmerge::TransitionEmerge(float duration)
|
||||
: Transition(duration)
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::ETransitionEmerge::_update()
|
||||
void e2d::TransitionEmerge::_update()
|
||||
{
|
||||
this->_calcRateOfProgress();
|
||||
|
||||
|
|
@ -19,13 +19,13 @@ void e2d::ETransitionEmerge::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETransitionEmerge::_init()
|
||||
void e2d::TransitionEmerge::_init()
|
||||
{
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setOpacity(1);
|
||||
m_pNextScene->getRoot()->setOpacity(0);
|
||||
}
|
||||
|
||||
void e2d::ETransitionEmerge::_reset()
|
||||
void e2d::TransitionEmerge::_reset()
|
||||
{
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setOpacity(1);
|
||||
m_pNextScene->getRoot()->setOpacity(1);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ETransitionFade::ETransitionFade(float fadeOutDuration, float fadeInDuration)
|
||||
: ETransition(0)
|
||||
e2d::TransitionFade::TransitionFade(float fadeOutDuration, float fadeInDuration)
|
||||
: Transition(0)
|
||||
, m_fFadeOutDuration(fadeOutDuration)
|
||||
, m_fFadeInDuration(fadeInDuration)
|
||||
, m_bFadeOutTransioning(true)
|
||||
|
|
@ -10,7 +10,7 @@ e2d::ETransitionFade::ETransitionFade(float fadeOutDuration, float fadeInDuratio
|
|||
m_fDuration = max(m_fFadeOutDuration, 0);
|
||||
}
|
||||
|
||||
void e2d::ETransitionFade::_update()
|
||||
void e2d::TransitionFade::_update()
|
||||
{
|
||||
this->_calcRateOfProgress();
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ void e2d::ETransitionFade::_update()
|
|||
{
|
||||
m_bFadeOutTransioning = false;
|
||||
m_fDuration = max(m_fFadeInDuration, 0);
|
||||
m_fLast = ETime::getTotalTime();
|
||||
m_fLast = Time::getTotalTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -34,7 +34,7 @@ void e2d::ETransitionFade::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETransitionFade::_init()
|
||||
void e2d::TransitionFade::_init()
|
||||
{
|
||||
if (m_pPrevScene)
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ void e2d::ETransitionFade::_init()
|
|||
m_pNextScene->getRoot()->setOpacity(0);
|
||||
}
|
||||
|
||||
void e2d::ETransitionFade::_reset()
|
||||
void e2d::TransitionFade::_reset()
|
||||
{
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setOpacity(1);
|
||||
m_pNextScene->getRoot()->setOpacity(1);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ETransitionMove::ETransitionMove(float duration, MOVE_DIRECT direct)
|
||||
: ETransition(duration)
|
||||
e2d::TransitionMove::TransitionMove(float duration, MOVE_DIRECT direct)
|
||||
: Transition(duration)
|
||||
, m_Direct(direct)
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::ETransitionMove::_update()
|
||||
void e2d::TransitionMove::_update()
|
||||
{
|
||||
this->_calcRateOfProgress();
|
||||
|
||||
|
|
@ -20,34 +20,34 @@ void e2d::ETransitionMove::_update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ETransitionMove::_init()
|
||||
void e2d::TransitionMove::_init()
|
||||
{
|
||||
if (m_Direct == ETransitionMove::UP)
|
||||
if (m_Direct == TransitionMove::UP)
|
||||
{
|
||||
m_Vec = EVector2(0, -EWindow::getHeight());
|
||||
m_NextPos = EPoint(0, EWindow::getHeight());
|
||||
m_Vec = Vector(0, -Window::getHeight());
|
||||
m_NextPos = Point(0, Window::getHeight());
|
||||
}
|
||||
else if (m_Direct == ETransitionMove::DOWN)
|
||||
else if (m_Direct == TransitionMove::DOWN)
|
||||
{
|
||||
m_Vec = EVector2(0, EWindow::getHeight());
|
||||
m_NextPos = EPoint(0, -EWindow::getHeight());
|
||||
m_Vec = Vector(0, Window::getHeight());
|
||||
m_NextPos = Point(0, -Window::getHeight());
|
||||
}
|
||||
else if (m_Direct == ETransitionMove::LEFT)
|
||||
else if (m_Direct == TransitionMove::LEFT)
|
||||
{
|
||||
m_Vec = EVector2(-EWindow::getWidth(), 0);
|
||||
m_NextPos = EPoint(EWindow::getWidth(), 0);
|
||||
m_Vec = Vector(-Window::getWidth(), 0);
|
||||
m_NextPos = Point(Window::getWidth(), 0);
|
||||
}
|
||||
else if (m_Direct == ETransitionMove::RIGHT)
|
||||
else if (m_Direct == TransitionMove::RIGHT)
|
||||
{
|
||||
m_Vec = EVector2(EWindow::getWidth(), 0);
|
||||
m_NextPos = EPoint(-EWindow::getWidth(), 0);
|
||||
m_Vec = Vector(Window::getWidth(), 0);
|
||||
m_NextPos = Point(-Window::getWidth(), 0);
|
||||
}
|
||||
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
|
||||
m_pNextScene->getRoot()->setPos(m_NextPos);
|
||||
}
|
||||
|
||||
void e2d::ETransitionMove::_reset()
|
||||
void e2d::TransitionMove::_reset()
|
||||
{
|
||||
if (m_pPrevScene) m_pPrevScene->getRoot()->setPos(0, 0);
|
||||
m_pNextScene->getRoot()->setPos(0, 0);
|
||||
|
|
|
|||
281
core/eactions.h
281
core/eactions.h
|
|
@ -5,33 +5,33 @@ namespace e2d
|
|||
{
|
||||
|
||||
|
||||
class EActionManager;
|
||||
class EActionTwo;
|
||||
class EActionLoop;
|
||||
class EActionSequence;
|
||||
class ActionManager;
|
||||
class ActionTwo;
|
||||
class ActionLoop;
|
||||
class ActionSequence;
|
||||
class EActionTwoAtSameTime;
|
||||
class ETransitionFade;
|
||||
class TransitionFade;
|
||||
|
||||
class EAction :
|
||||
public EObject
|
||||
class Action :
|
||||
public Obj
|
||||
{
|
||||
friend EActionManager;
|
||||
friend EActionTwo;
|
||||
friend EActionLoop;
|
||||
friend EActionSequence;
|
||||
friend ActionManager;
|
||||
friend ActionTwo;
|
||||
friend ActionLoop;
|
||||
friend ActionSequence;
|
||||
friend EActionTwoAtSameTime;
|
||||
|
||||
public:
|
||||
EAction();
|
||||
Action();
|
||||
|
||||
virtual ~EAction();
|
||||
virtual ~Action();
|
||||
|
||||
// 获取动作运行状态
|
||||
virtual bool isRunning();
|
||||
|
||||
// 开始动作
|
||||
virtual void startWith(
|
||||
ENode* pTarget /* 执行该动作的目标 */
|
||||
Node* pTarget /* 执行该动作的目标 */
|
||||
);
|
||||
|
||||
// 继续动作
|
||||
|
|
@ -44,16 +44,16 @@ public:
|
|||
virtual void stop();
|
||||
|
||||
// 获取一个新的拷贝动作
|
||||
virtual EAction * clone() const = 0;
|
||||
virtual Action * clone() const = 0;
|
||||
|
||||
// 获取一个新的逆向动作
|
||||
virtual EAction * reverse() const;
|
||||
virtual Action * reverse() const;
|
||||
|
||||
// 重置动作
|
||||
virtual void reset();
|
||||
|
||||
// 获取该动作的执行目标
|
||||
virtual ENode * getTarget();
|
||||
virtual Node * getTarget();
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
|
|
@ -72,18 +72,18 @@ protected:
|
|||
bool m_bRunning;
|
||||
bool m_bEnding;
|
||||
bool m_bInit;
|
||||
ENode * m_pTarget;
|
||||
EScene *m_pParentScene;
|
||||
Node * m_pTarget;
|
||||
Scene *m_pParentScene;
|
||||
float m_fLast;
|
||||
};
|
||||
|
||||
|
||||
class EActionGradual :
|
||||
public EAction
|
||||
class ActionGradual :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建时长动画
|
||||
EActionGradual(
|
||||
ActionGradual(
|
||||
float duration
|
||||
);
|
||||
|
||||
|
|
@ -100,21 +100,21 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionMoveBy :
|
||||
public EActionGradual
|
||||
class ActionMoveBy :
|
||||
public ActionGradual
|
||||
{
|
||||
public:
|
||||
// 创建相对位移动画
|
||||
EActionMoveBy(
|
||||
ActionMoveBy(
|
||||
float duration, /* 动画持续时长 */
|
||||
EVector2 vector /* 位移向量 */
|
||||
Vector vector /* 位移向量 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionMoveBy * clone() const override;
|
||||
virtual ActionMoveBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
virtual EActionMoveBy * reverse() const override;
|
||||
virtual ActionMoveBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -124,55 +124,55 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
EPoint m_BeginPos;
|
||||
EVector2 m_MoveVec;
|
||||
Point m_BeginPos;
|
||||
Vector m_MoveVec;
|
||||
};
|
||||
|
||||
|
||||
class EActionMoveTo :
|
||||
public EActionMoveBy
|
||||
class ActionMoveTo :
|
||||
public ActionMoveBy
|
||||
{
|
||||
public:
|
||||
// 创建位移动画
|
||||
EActionMoveTo(
|
||||
ActionMoveTo(
|
||||
float duration, /* 动画持续时长 */
|
||||
EPoint pos /* 位移至目标点的坐标 */
|
||||
Point pos /* 位移至目标点的坐标 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionMoveTo * clone() const override;
|
||||
virtual ActionMoveTo * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
virtual void _init() override;
|
||||
|
||||
protected:
|
||||
EPoint m_EndPos;
|
||||
Point m_EndPos;
|
||||
};
|
||||
|
||||
|
||||
class EActionScaleBy :
|
||||
public EActionGradual
|
||||
class ActionScaleBy :
|
||||
public ActionGradual
|
||||
{
|
||||
public:
|
||||
// 创建相对缩放动画
|
||||
EActionScaleBy(
|
||||
ActionScaleBy(
|
||||
float duration, /* 动画持续时长 */
|
||||
float scale /* 缩放比例变化 */
|
||||
);
|
||||
|
||||
// 创建相对缩放动画
|
||||
EActionScaleBy(
|
||||
ActionScaleBy(
|
||||
float duration, /* 动画持续时长 */
|
||||
float scaleX, /* 横向缩放比例变化 */
|
||||
float scaleY /* 纵向缩放比例变化 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionScaleBy * clone() const override;
|
||||
virtual ActionScaleBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
virtual EActionScaleBy * reverse() const override;
|
||||
virtual ActionScaleBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -189,25 +189,25 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionScaleTo :
|
||||
public EActionScaleBy
|
||||
class ActionScaleTo :
|
||||
public ActionScaleBy
|
||||
{
|
||||
public:
|
||||
// 创建缩放动画
|
||||
EActionScaleTo(
|
||||
ActionScaleTo(
|
||||
float duration, /* 动画持续时长 */
|
||||
float scale /* 缩放至目标比例 */
|
||||
);
|
||||
|
||||
// 创建缩放动画
|
||||
EActionScaleTo(
|
||||
ActionScaleTo(
|
||||
float duration, /* 动画持续时长 */
|
||||
float scaleX, /* 横向缩放至目标比例 */
|
||||
float scaleY /* 纵向缩放至目标比例 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionScaleTo * clone() const override;
|
||||
virtual ActionScaleTo * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -219,21 +219,21 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionOpacityBy :
|
||||
public EActionGradual
|
||||
class ActionOpacityBy :
|
||||
public ActionGradual
|
||||
{
|
||||
public:
|
||||
// 创建透明度相对渐变动画
|
||||
EActionOpacityBy(
|
||||
ActionOpacityBy(
|
||||
float duration, /* 动画持续时长 */
|
||||
float opacity /* 透明度相对变化值 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionOpacityBy * clone() const override;
|
||||
virtual ActionOpacityBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
virtual EActionOpacityBy * reverse() const override;
|
||||
virtual ActionOpacityBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -248,18 +248,18 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionOpacityTo :
|
||||
public EActionOpacityBy
|
||||
class ActionOpacityTo :
|
||||
public ActionOpacityBy
|
||||
{
|
||||
public:
|
||||
// 创建透明度渐变动画
|
||||
EActionOpacityTo(
|
||||
ActionOpacityTo(
|
||||
float duration, /* 动画持续时长 */
|
||||
float opacity /* 透明度渐变至目标值 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionOpacityTo * clone() const override;
|
||||
virtual ActionOpacityTo * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -270,43 +270,43 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionFadeIn :
|
||||
public EActionOpacityTo
|
||||
class ActionFadeIn :
|
||||
public ActionOpacityTo
|
||||
{
|
||||
public:
|
||||
// 创建淡入动画
|
||||
EActionFadeIn(
|
||||
ActionFadeIn(
|
||||
float duration /* 动画持续时长 */
|
||||
) : EActionOpacityTo(duration, 1) {}
|
||||
) : ActionOpacityTo(duration, 1) {}
|
||||
};
|
||||
|
||||
|
||||
class EActionFadeOut :
|
||||
public EActionOpacityTo
|
||||
class ActionFadeOut :
|
||||
public ActionOpacityTo
|
||||
{
|
||||
public:
|
||||
// 创建淡出动画
|
||||
EActionFadeOut(
|
||||
ActionFadeOut(
|
||||
float duration /* 动画持续时长 */
|
||||
) : EActionOpacityTo(duration, 0) {}
|
||||
) : ActionOpacityTo(duration, 0) {}
|
||||
};
|
||||
|
||||
|
||||
class EActionRotateBy :
|
||||
public EActionGradual
|
||||
class ActionRotateBy :
|
||||
public ActionGradual
|
||||
{
|
||||
public:
|
||||
// 创建相对旋转动画
|
||||
EActionRotateBy(
|
||||
ActionRotateBy(
|
||||
float duration, /* 动画持续时长 */
|
||||
float rotation /* 旋转角度变化值 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionRotateBy * clone() const override;
|
||||
virtual ActionRotateBy * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
virtual EActionRotateBy * reverse() const override;
|
||||
virtual ActionRotateBy * reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -321,18 +321,18 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionRotateTo :
|
||||
public EActionRotateBy
|
||||
class ActionRotateTo :
|
||||
public ActionRotateBy
|
||||
{
|
||||
public:
|
||||
// 创建旋转动画
|
||||
EActionRotateTo(
|
||||
ActionRotateTo(
|
||||
float duration, /* 动画持续时长 */
|
||||
float rotation /* 旋转角度至目标值 */
|
||||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EActionRotateTo * clone() const override;
|
||||
virtual ActionRotateTo * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动画
|
||||
|
|
@ -343,23 +343,24 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionTwo :
|
||||
public EAction
|
||||
class ActionTwo :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建两个动作的连续动作
|
||||
EActionTwo(
|
||||
EAction * actionFirst, /* 第一个动作 */
|
||||
EAction * actionSecond /* 第二个动作 */
|
||||
ActionTwo(
|
||||
Action * pActionFirst, /* 第一个动作 */
|
||||
Action * pActionSecond, /* 第二个动作 */
|
||||
bool bAtSameTime = false /* 同时开始 */
|
||||
);
|
||||
|
||||
virtual ~EActionTwo();
|
||||
virtual ~ActionTwo();
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionTwo * clone() const override;
|
||||
virtual ActionTwo * clone() const override;
|
||||
|
||||
// 获取该动作的逆动作
|
||||
virtual EActionTwo * reverse(
|
||||
virtual ActionTwo * reverse(
|
||||
bool actionReverse = true /* 子动作是否执行逆动作 */
|
||||
) const;
|
||||
|
||||
|
|
@ -377,37 +378,38 @@ protected:
|
|||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
EAction * m_pFirstAction;
|
||||
EAction * m_pSecondAction;
|
||||
Action* m_pFirstAction;
|
||||
Action* m_pSecondAction;
|
||||
bool m_bAtSameTime;
|
||||
};
|
||||
|
||||
|
||||
class EActionSequence :
|
||||
public EAction
|
||||
class ActionSequence :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建顺序动作
|
||||
EActionSequence();
|
||||
ActionSequence();
|
||||
|
||||
// 创建顺序动作
|
||||
EActionSequence(
|
||||
ActionSequence(
|
||||
int number, /* 顺序动作数量 */
|
||||
EAction * action1, /* 第一个动作 */
|
||||
Action * action1, /* 第一个动作 */
|
||||
...
|
||||
);
|
||||
|
||||
virtual ~EActionSequence();
|
||||
virtual ~ActionSequence();
|
||||
|
||||
// 向顺序动作中添加动作
|
||||
void addAction(
|
||||
EAction * action /* 将动作添加至顺序动作尾部 */
|
||||
void _add(
|
||||
Action * action /* 将动作添加至顺序动作尾部 */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionSequence * clone() const override;
|
||||
virtual ActionSequence * clone() const override;
|
||||
|
||||
// 获取该动作的逆动作
|
||||
virtual EActionSequence * reverse(
|
||||
virtual ActionSequence * reverse(
|
||||
bool actionReverse = true /* 子动作是否执行逆动作 */
|
||||
) const;
|
||||
|
||||
|
|
@ -426,21 +428,21 @@ protected:
|
|||
|
||||
protected:
|
||||
UINT m_nActionIndex;
|
||||
std::vector<EAction*> m_vActions;
|
||||
std::vector<Action*> m_vActions;
|
||||
};
|
||||
|
||||
|
||||
class EActionDelay :
|
||||
public EAction
|
||||
class ActionDelay :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建延时动作
|
||||
EActionDelay(
|
||||
ActionDelay(
|
||||
float duration /* 延迟时长(秒) */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionDelay * clone() const override;
|
||||
virtual ActionDelay * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
|
|
@ -454,59 +456,20 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EActionTwoAtSameTime :
|
||||
public EAction
|
||||
{
|
||||
public:
|
||||
// 创建两个动作同时执行的动作
|
||||
EActionTwoAtSameTime(
|
||||
EAction * actionFirst, /* 第一个动作 */
|
||||
EAction * actionSecond /* 第二个动作 */
|
||||
);
|
||||
|
||||
virtual ~EActionTwoAtSameTime();
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionTwoAtSameTime * clone() const override;
|
||||
|
||||
// 获取该动作的逆动作
|
||||
virtual EActionTwoAtSameTime * reverse(
|
||||
bool actionReverse = true /* 子动作是否执行逆动作 */
|
||||
) const;
|
||||
|
||||
// 重置动作
|
||||
virtual void reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void _init() override;
|
||||
|
||||
// 执行动作
|
||||
virtual void _update() override;
|
||||
|
||||
// 重置动画时间
|
||||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
EAction * m_pFirstAction;
|
||||
EAction * m_pSecondAction;
|
||||
};
|
||||
|
||||
|
||||
class EActionLoop :
|
||||
public EAction
|
||||
class ActionLoop :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建循环动作
|
||||
EActionLoop(
|
||||
EAction * action, /* 执行循环的动作 */
|
||||
ActionLoop(
|
||||
Action * action, /* 执行循环的动作 */
|
||||
int times = -1 /* 循环次数 */
|
||||
);
|
||||
|
||||
virtual ~EActionLoop();
|
||||
virtual ~ActionLoop();
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionLoop * clone() const override;
|
||||
virtual ActionLoop * clone() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void reset() override;
|
||||
|
|
@ -522,29 +485,29 @@ protected:
|
|||
virtual void _resetTime() override;
|
||||
|
||||
protected:
|
||||
EAction * m_pAction;
|
||||
Action * m_pAction;
|
||||
int m_nTimes;
|
||||
int m_nTotalTimes;
|
||||
};
|
||||
|
||||
|
||||
class EAnimation :
|
||||
public EAction
|
||||
class Animation :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建帧动画
|
||||
EAnimation();
|
||||
Animation();
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
EAnimation(
|
||||
Animation(
|
||||
float interval /* 帧间隔(秒) */
|
||||
);
|
||||
|
||||
virtual ~EAnimation();
|
||||
virtual ~Animation();
|
||||
|
||||
// 添加关键帧
|
||||
void addKeyframe(
|
||||
EImage * frame /* 添加关键帧 */
|
||||
Image * frame /* 添加关键帧 */
|
||||
);
|
||||
|
||||
// 设置每一帧的时间间隔
|
||||
|
|
@ -553,10 +516,10 @@ public:
|
|||
);
|
||||
|
||||
// 获取该动画的拷贝对象
|
||||
virtual EAnimation * clone() const override;
|
||||
virtual Animation * clone() const override;
|
||||
|
||||
// 获取该动画的逆动画
|
||||
virtual EAnimation * reverse() const override;
|
||||
virtual Animation * reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void reset() override;
|
||||
|
|
@ -571,21 +534,21 @@ protected:
|
|||
protected:
|
||||
float m_fInterval;
|
||||
UINT m_nFrameIndex;
|
||||
std::vector<EImage*> m_vFrames;
|
||||
std::vector<Image*> m_vFrames;
|
||||
};
|
||||
|
||||
|
||||
class EActionCallback :
|
||||
public EAction
|
||||
class ActionCallback :
|
||||
public Action
|
||||
{
|
||||
public:
|
||||
// 创建执行回调函数的动作
|
||||
EActionCallback(
|
||||
const std::function<void()> & callback /* 回调函数 */
|
||||
ActionCallback(
|
||||
const VoidFunction & callback /* 回调函数 */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual EActionCallback * clone() const override;
|
||||
virtual ActionCallback * clone() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
|
|
@ -595,7 +558,7 @@ protected:
|
|||
virtual void _update() override;
|
||||
|
||||
protected:
|
||||
std::function<void()> m_Callback;
|
||||
VoidFunction m_Callback;
|
||||
};
|
||||
|
||||
}
|
||||
30
core/ebase.h
30
core/ebase.h
|
|
@ -9,7 +9,7 @@ namespace e2d
|
|||
{
|
||||
|
||||
|
||||
class EGame
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
// 初始化游戏
|
||||
|
|
@ -40,18 +40,18 @@ public:
|
|||
static bool isPaused();
|
||||
|
||||
// 获取 AppName
|
||||
static EString getAppName();
|
||||
static String getAppName();
|
||||
};
|
||||
|
||||
|
||||
// 控制窗口属性
|
||||
class EWindow
|
||||
class Window
|
||||
{
|
||||
friend EGame;
|
||||
friend Game;
|
||||
|
||||
public:
|
||||
// 获取窗口标题
|
||||
static EString getTitle();
|
||||
static String getTitle();
|
||||
|
||||
// 获取窗口宽度
|
||||
static float getWidth();
|
||||
|
|
@ -60,7 +60,7 @@ public:
|
|||
static float getHeight();
|
||||
|
||||
// 获取窗口大小
|
||||
static ESize getSize();
|
||||
static Size getSize();
|
||||
|
||||
// 获取窗口句柄
|
||||
static HWND getHWnd();
|
||||
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
// 设置窗口标题
|
||||
static void setTitle(
|
||||
const EString & sTitle
|
||||
const String & sTitle
|
||||
);
|
||||
|
||||
// 打开/隐藏控制台
|
||||
|
|
@ -107,9 +107,9 @@ private:
|
|||
|
||||
|
||||
// 控制游戏时间
|
||||
class ETime
|
||||
class Time
|
||||
{
|
||||
friend EGame;
|
||||
friend Game;
|
||||
|
||||
public:
|
||||
// 获取上一帧与当前帧的时间间隔(毫秒)
|
||||
|
|
@ -140,9 +140,9 @@ private:
|
|||
|
||||
|
||||
// 控制键盘和鼠标的输入
|
||||
class EInput
|
||||
class Input
|
||||
{
|
||||
friend EGame;
|
||||
friend Game;
|
||||
|
||||
public:
|
||||
// 检测键盘某按键是否正被按下
|
||||
|
|
@ -194,7 +194,7 @@ public:
|
|||
static float getMouseY();
|
||||
|
||||
// 获得鼠标坐标值
|
||||
static EPoint getMousePos();
|
||||
static Point getMousePos();
|
||||
|
||||
// 获得鼠标X轴坐标增量
|
||||
static float getMouseDeltaX();
|
||||
|
|
@ -218,10 +218,10 @@ private:
|
|||
|
||||
|
||||
// 渲染器
|
||||
class ERenderer
|
||||
class Renderer
|
||||
{
|
||||
friend EGame;
|
||||
friend EWindow;
|
||||
friend Game;
|
||||
friend Window;
|
||||
|
||||
public:
|
||||
// 修改背景色
|
||||
|
|
|
|||
237
core/ecommon.h
237
core/ecommon.h
|
|
@ -9,157 +9,157 @@ namespace e2d
|
|||
|
||||
|
||||
// 表示坐标的结构体
|
||||
struct EPoint
|
||||
struct Point
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
|
||||
EPoint()
|
||||
Point()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
EPoint(float x, float y)
|
||||
Point(float x, float y)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
EPoint operator + (EPoint const & p)
|
||||
Point operator + (Point const & p)
|
||||
{
|
||||
return EPoint(x + p.x, y + p.y);
|
||||
return Point(x + p.x, y + p.y);
|
||||
}
|
||||
|
||||
EPoint operator - (EPoint const & p)
|
||||
Point operator - (Point const & p)
|
||||
{
|
||||
return EPoint(x - p.x, y - p.y);
|
||||
return Point(x - p.x, y - p.y);
|
||||
}
|
||||
|
||||
EPoint operator * (float const & value)
|
||||
Point operator * (float const & value)
|
||||
{
|
||||
return EPoint(x * value, y * value);
|
||||
return Point(x * value, y * value);
|
||||
}
|
||||
|
||||
EPoint operator / (float const & value)
|
||||
Point operator / (float const & value)
|
||||
{
|
||||
return EPoint(x / value, y / value);
|
||||
return Point(x / value, y / value);
|
||||
}
|
||||
};
|
||||
|
||||
// 表示大小的结构体
|
||||
struct ESize
|
||||
struct Size
|
||||
{
|
||||
float width;
|
||||
float height;
|
||||
|
||||
ESize()
|
||||
Size()
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
ESize(float width, float height)
|
||||
Size(float width, float height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
ESize operator + (ESize const & size)
|
||||
Size operator + (Size const & size)
|
||||
{
|
||||
return ESize(width + size.width, height + size.height);
|
||||
return Size(width + size.width, height + size.height);
|
||||
}
|
||||
|
||||
ESize operator - (ESize const & size)
|
||||
Size operator - (Size const & size)
|
||||
{
|
||||
return ESize(width - size.width, height - size.height);
|
||||
return Size(width - size.width, height - size.height);
|
||||
}
|
||||
|
||||
ESize operator * (float const & value)
|
||||
Size operator * (float const & value)
|
||||
{
|
||||
return ESize(width * value, height * value);
|
||||
return Size(width * value, height * value);
|
||||
}
|
||||
|
||||
ESize operator / (float const & value)
|
||||
Size operator / (float const & value)
|
||||
{
|
||||
return ESize(width / value, height / value);
|
||||
return Size(width / value, height / value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 字符串
|
||||
class EString
|
||||
class String
|
||||
{
|
||||
public:
|
||||
EString();
|
||||
EString(const wchar_t);
|
||||
EString(const wchar_t *);
|
||||
EString(const EString &);
|
||||
EString(const std::wstring &);
|
||||
EString(EString &&);
|
||||
String();
|
||||
String(const wchar_t);
|
||||
String(const wchar_t *);
|
||||
String(const String &);
|
||||
String(const std::wstring &);
|
||||
String(String &&);
|
||||
|
||||
~EString();
|
||||
~String();
|
||||
|
||||
EString& operator=(const wchar_t *);
|
||||
EString& operator=(const EString &);
|
||||
EString& operator=(const std::wstring &);
|
||||
String& operator=(const wchar_t *);
|
||||
String& operator=(const String &);
|
||||
String& operator=(const std::wstring &);
|
||||
|
||||
bool operator==(const wchar_t *);
|
||||
bool operator==(const EString &);
|
||||
bool operator==(const String &);
|
||||
bool operator==(const std::wstring &);
|
||||
|
||||
bool operator!=(const wchar_t *);
|
||||
bool operator!=(const EString &);
|
||||
bool operator!=(const String &);
|
||||
bool operator!=(const std::wstring &);
|
||||
|
||||
wchar_t &operator[](int);
|
||||
|
||||
EString operator+(const wchar_t);
|
||||
EString operator+(const wchar_t *);
|
||||
EString operator+(const EString &);
|
||||
EString operator+(const std::wstring &);
|
||||
String operator+(const wchar_t);
|
||||
String operator+(const wchar_t *);
|
||||
String operator+(const String &);
|
||||
String operator+(const std::wstring &);
|
||||
|
||||
template<typename T>
|
||||
EString operator+(const T value)
|
||||
String operator+(const T value)
|
||||
{
|
||||
EString str_temp(*this);
|
||||
String str_temp(*this);
|
||||
|
||||
str_temp += value;
|
||||
return std::move(str_temp);
|
||||
}
|
||||
|
||||
EString &operator +=(const wchar_t);
|
||||
EString &operator +=(const wchar_t *);
|
||||
EString &operator +=(const EString &);
|
||||
EString &operator +=(const std::wstring &);
|
||||
String &operator +=(const wchar_t);
|
||||
String &operator +=(const wchar_t *);
|
||||
String &operator +=(const String &);
|
||||
String &operator +=(const std::wstring &);
|
||||
|
||||
template<typename T>
|
||||
EString &operator +=(const T value)
|
||||
String &operator +=(const T value)
|
||||
{
|
||||
std::wostringstream ss;
|
||||
ss << value;
|
||||
return (*this) += ss.str();
|
||||
}
|
||||
|
||||
bool operator < (EString const&) const;
|
||||
bool operator <= (EString const&) const;
|
||||
bool operator > (EString const&) const;
|
||||
bool operator >= (EString const&) const;
|
||||
bool operator < (String const&) const;
|
||||
bool operator <= (String const&) const;
|
||||
bool operator > (String const&) const;
|
||||
bool operator >= (String const&) const;
|
||||
|
||||
operator wchar_t*() const { return _string; }
|
||||
operator bool() const { return _size != 0; }
|
||||
|
||||
friend EString operator+(const wchar_t, const EString &);
|
||||
friend EString operator+(const wchar_t*, const EString &);
|
||||
friend EString operator+(const EString &, const EString &);
|
||||
friend EString operator+(const std::wstring &, const EString &);
|
||||
friend String operator+(const wchar_t, const String &);
|
||||
friend String operator+(const wchar_t*, const String &);
|
||||
friend String operator+(const String &, const String &);
|
||||
friend String operator+(const std::wstring &, const String &);
|
||||
template<typename T>
|
||||
friend EString operator+(const T &value, const EString &str)
|
||||
friend String operator+(const T &value, const String &str)
|
||||
{
|
||||
return std::move((EString::parse(value) + str2));
|
||||
return std::move((String::parse(value) + str2));
|
||||
}
|
||||
|
||||
friend std::wistream &operator>>(std::wistream &, EString &);
|
||||
friend std::wistream &operator>>(std::wistream &, String &);
|
||||
|
||||
// 判断字符串是否为空
|
||||
bool isEmpty() const { return _size == 0; }
|
||||
|
|
@ -168,13 +168,13 @@ public:
|
|||
int length() const { return _size; }
|
||||
|
||||
// 获取大写字符串
|
||||
EString upper() const;
|
||||
String upper() const;
|
||||
|
||||
// 获取小写字符串
|
||||
EString lower() const;
|
||||
String lower() const;
|
||||
|
||||
// 获取裁剪字符串
|
||||
EString sub(int offset, int count = -1) const;
|
||||
String sub(int offset, int count = -1) const;
|
||||
|
||||
// 获取字符串中第一个特定字符的下标
|
||||
int findFirstOf(const wchar_t ch) const;
|
||||
|
|
@ -183,17 +183,17 @@ public:
|
|||
int findLastOf(const wchar_t ch) const;
|
||||
|
||||
// 后接字符
|
||||
EString &append(const wchar_t ch);
|
||||
String &append(const wchar_t ch);
|
||||
|
||||
// 后接字符串
|
||||
EString &append(const wchar_t *str);
|
||||
String &append(const wchar_t *str);
|
||||
|
||||
// 后接字符串
|
||||
EString &append(const EString &str);
|
||||
String &append(const String &str);
|
||||
|
||||
// 后接字符串
|
||||
template<typename T>
|
||||
EString &append(const T &value)
|
||||
String &append(const T &value)
|
||||
{
|
||||
return (*this) += value;
|
||||
}
|
||||
|
|
@ -203,9 +203,9 @@ public:
|
|||
|
||||
// 将模板类型转化为字符串
|
||||
template<typename T>
|
||||
static EString parse(const T value)
|
||||
static String parse(const T value)
|
||||
{
|
||||
EString str;
|
||||
String str;
|
||||
|
||||
std::wostringstream ss;
|
||||
ss << value;
|
||||
|
|
@ -221,7 +221,7 @@ private:
|
|||
|
||||
|
||||
// 颜色
|
||||
class EColor
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
enum COMMON_VALUE
|
||||
|
|
@ -292,7 +292,7 @@ public:
|
|||
};
|
||||
|
||||
// 字体粗细值
|
||||
class EFontWeight
|
||||
class FontWeight
|
||||
{
|
||||
public:
|
||||
enum COMMON_VALUE
|
||||
|
|
@ -319,7 +319,7 @@ public:
|
|||
|
||||
|
||||
// 键值集合
|
||||
class EKeyCode
|
||||
class KeyCode
|
||||
{
|
||||
public:
|
||||
enum VALUE
|
||||
|
|
@ -395,7 +395,7 @@ public:
|
|||
|
||||
|
||||
// 形状交集关系
|
||||
class ERelation
|
||||
class Relation
|
||||
{
|
||||
public:
|
||||
enum VALUE
|
||||
|
|
@ -409,17 +409,17 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class EObjectManager;
|
||||
class ObjectManager;
|
||||
|
||||
// 基础对象
|
||||
class EObject
|
||||
class Obj
|
||||
{
|
||||
friend EObjectManager;
|
||||
friend ObjectManager;
|
||||
|
||||
public:
|
||||
EObject();
|
||||
Obj();
|
||||
|
||||
virtual ~EObject();
|
||||
virtual ~Obj();
|
||||
|
||||
// 引用计数加一
|
||||
void retain();
|
||||
|
|
@ -433,25 +433,25 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class EText;
|
||||
class Text;
|
||||
|
||||
class EFont :
|
||||
public EObject
|
||||
class Font :
|
||||
public Obj
|
||||
{
|
||||
friend EText;
|
||||
friend Text;
|
||||
|
||||
public:
|
||||
EFont();
|
||||
Font();
|
||||
|
||||
EFont(
|
||||
EString fontFamily,
|
||||
Font(
|
||||
String fontFamily,
|
||||
float fontSize = 22,
|
||||
UINT32 color = EColor::WHITE,
|
||||
UINT32 fontWeight = EFontWeight::REGULAR,
|
||||
UINT32 color = Color::WHITE,
|
||||
UINT32 fontWeight = FontWeight::REGULAR,
|
||||
bool italic = false
|
||||
);
|
||||
|
||||
virtual ~EFont();
|
||||
virtual ~Font();
|
||||
|
||||
// 获取当前字号
|
||||
float getFontSize() const;
|
||||
|
|
@ -467,7 +467,7 @@ public:
|
|||
|
||||
// 设置字体
|
||||
void setFamily(
|
||||
const EString & fontFamily
|
||||
const String & fontFamily
|
||||
);
|
||||
|
||||
// 设置字号
|
||||
|
|
@ -498,7 +498,7 @@ protected:
|
|||
IDWriteTextFormat * _getTextFormat();
|
||||
|
||||
protected:
|
||||
EString m_sFontFamily;
|
||||
String m_sFontFamily;
|
||||
float m_fFontSize;
|
||||
UINT32 m_FontWeight;
|
||||
UINT32 m_Color;
|
||||
|
|
@ -509,20 +509,20 @@ protected:
|
|||
|
||||
|
||||
// 图片
|
||||
class EImage :
|
||||
public EObject
|
||||
class Image :
|
||||
public Obj
|
||||
{
|
||||
public:
|
||||
// 创建一个空的图片
|
||||
EImage();
|
||||
Image();
|
||||
|
||||
// 从本地文件中读取资源
|
||||
EImage(
|
||||
Image(
|
||||
LPCTSTR strFilePath /* 图片文件路径 */
|
||||
);
|
||||
|
||||
// 从本地文件中读取资源
|
||||
EImage(
|
||||
Image(
|
||||
LPCTSTR strFilePath,/* 图片文件路径 */
|
||||
float nClipX, /* 裁剪位置 X 坐标 */
|
||||
float nClipY, /* 裁剪位置 Y 坐标 */
|
||||
|
|
@ -530,7 +530,7 @@ public:
|
|||
float nClipHeight /* 裁剪高度 */
|
||||
);
|
||||
|
||||
virtual ~EImage();
|
||||
virtual ~Image();
|
||||
|
||||
// 裁剪图片
|
||||
void clip(
|
||||
|
|
@ -542,12 +542,12 @@ public:
|
|||
|
||||
// 从本地文件中读取图片
|
||||
void loadFrom(
|
||||
const EString & strFilePath
|
||||
const String & strFilePath
|
||||
);
|
||||
|
||||
// 从本地文件中读取图片并裁剪
|
||||
void loadFrom(
|
||||
const EString & strFilePath,/* 图片文件路径 */
|
||||
const String & strFilePath,/* 图片文件路径 */
|
||||
float nClipX, /* 裁剪位置 X 坐标 */
|
||||
float nClipY, /* 裁剪位置 Y 坐标 */
|
||||
float nClipWidth, /* 裁剪宽度 */
|
||||
|
|
@ -561,7 +561,7 @@ public:
|
|||
virtual float getHeight() const;
|
||||
|
||||
// 获取大小
|
||||
virtual ESize getSize() const;
|
||||
virtual Size getSize() const;
|
||||
|
||||
// 获取源图片宽度
|
||||
virtual float getSourceWidth() const;
|
||||
|
|
@ -570,7 +570,7 @@ public:
|
|||
virtual float getSourceHeight() const;
|
||||
|
||||
// 获取源图片大小
|
||||
virtual ESize getSourceSize() const;
|
||||
virtual Size getSourceSize() const;
|
||||
|
||||
// 获取裁剪位置 X 坐标
|
||||
virtual float getClipX() const;
|
||||
|
|
@ -579,14 +579,14 @@ public:
|
|||
virtual float getClipY() const;
|
||||
|
||||
// 获取裁剪位置
|
||||
virtual EPoint getClipPos() const;
|
||||
virtual Point getClipPos() const;
|
||||
|
||||
// 获取 ID2D1Bitmap 对象
|
||||
ID2D1Bitmap * getBitmap();
|
||||
|
||||
// 预加载资源
|
||||
static bool preload(
|
||||
const EString & sFileName /* 图片文件路径 */
|
||||
const String & sFileName /* 图片文件路径 */
|
||||
);
|
||||
|
||||
// 清空缓存
|
||||
|
|
@ -601,20 +601,20 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ESceneManager;
|
||||
class ENode;
|
||||
class EAction;
|
||||
class SceneManager;
|
||||
class Node;
|
||||
class Action;
|
||||
|
||||
// 场景
|
||||
class EScene :
|
||||
public EObject
|
||||
class Scene :
|
||||
public Obj
|
||||
{
|
||||
friend ESceneManager;
|
||||
friend SceneManager;
|
||||
|
||||
public:
|
||||
EScene();
|
||||
Scene();
|
||||
|
||||
virtual ~EScene();
|
||||
virtual ~Scene();
|
||||
|
||||
// 重写这个函数,它将在进入这个场景时自动执行
|
||||
virtual void onEnter() {}
|
||||
|
|
@ -624,8 +624,8 @@ public:
|
|||
|
||||
// 重写这个函数,它将在碰撞发生时自动执行
|
||||
virtual void onCollide(
|
||||
ENode * pActiveNode, /* 主动发生碰撞的节点 */
|
||||
ENode * pPassiveNode /* 被动发生碰撞的节点 */
|
||||
Node * pActiveNode, /* 主动发生碰撞的节点 */
|
||||
Node * pPassiveNode /* 被动发生碰撞的节点 */
|
||||
) {}
|
||||
|
||||
// 重写这个函数,它将在关闭窗口时执行
|
||||
|
|
@ -644,17 +644,17 @@ public:
|
|||
|
||||
// 添加节点到场景
|
||||
void add(
|
||||
ENode * child,
|
||||
Node * child,
|
||||
int zOrder = 0
|
||||
);
|
||||
|
||||
// 删除子节点
|
||||
bool remove(
|
||||
ENode * child
|
||||
Node * child
|
||||
);
|
||||
|
||||
// 获取根节点
|
||||
ENode * getRoot() const;
|
||||
Node * getRoot() const;
|
||||
|
||||
// 开启几何图形的渲染
|
||||
void setShapeVisiable(
|
||||
|
|
@ -673,18 +673,21 @@ protected:
|
|||
bool m_bSortNeeded;
|
||||
bool m_bWillSave;
|
||||
bool m_bShapeVisiable;
|
||||
ENode * m_pRoot;
|
||||
Node * m_pRoot;
|
||||
};
|
||||
|
||||
|
||||
// 二维向量
|
||||
typedef EPoint EVector2;
|
||||
typedef Point Vector;
|
||||
|
||||
// 定时器回调函数(参数为该定时器被调用的次数,从 0 开始)
|
||||
typedef std::function<void(int)> TimerCallback;
|
||||
// 返回值和参数列表都为空的函数
|
||||
typedef std::function<void(void)> VoidFunction;
|
||||
|
||||
// 定时器回调函数
|
||||
typedef VoidFunction TimerCallback;
|
||||
|
||||
// 按钮点击回调函数
|
||||
typedef std::function<void()> BtnClkCallback;
|
||||
typedef VoidFunction ButtonCallback;
|
||||
|
||||
template<typename T>
|
||||
inline void SafeDelete(T** p) { if (*p) { delete *p; *p = nullptr; } }
|
||||
|
|
|
|||
131
core/emanagers.h
131
core/emanagers.h
|
|
@ -5,27 +5,26 @@
|
|||
namespace e2d
|
||||
{
|
||||
|
||||
class EGame;
|
||||
class ERenderer;
|
||||
class EObject;
|
||||
class EScene;
|
||||
class ENode;
|
||||
class ETimer;
|
||||
class EAction;
|
||||
class EMusic;
|
||||
class EShape;
|
||||
class ETransition;
|
||||
class EListenerPhysics;
|
||||
class Game;
|
||||
class Renderer;
|
||||
class Obj;
|
||||
class Scene;
|
||||
class Node;
|
||||
class Timer;
|
||||
class Action;
|
||||
class Music;
|
||||
class Shape;
|
||||
class Transition;
|
||||
|
||||
// 对象管理器
|
||||
class EObjectManager
|
||||
class ObjectManager
|
||||
{
|
||||
friend EGame;
|
||||
friend Game;
|
||||
|
||||
public:
|
||||
// 将一个节点放入内存池
|
||||
static void add(
|
||||
e2d::EObject * nptr
|
||||
e2d::Obj * nptr
|
||||
);
|
||||
|
||||
// 通知内存池刷新
|
||||
|
|
@ -38,29 +37,29 @@ private:
|
|||
|
||||
|
||||
// 场景管理器
|
||||
class ESceneManager
|
||||
class SceneManager
|
||||
{
|
||||
friend EGame;
|
||||
friend ERenderer;
|
||||
friend Game;
|
||||
friend Renderer;
|
||||
|
||||
public:
|
||||
// 切换场景
|
||||
static void enterScene(
|
||||
EScene * scene, /* 下一个场景的指针 */
|
||||
ETransition * transition = nullptr, /* 场景切换动画 */
|
||||
Scene * scene, /* 下一个场景的指针 */
|
||||
Transition * transition = nullptr, /* 场景切换动画 */
|
||||
bool saveCurrentScene = true /* 是否保存当前场景 */
|
||||
);
|
||||
|
||||
// 返回上一场景
|
||||
static void backScene(
|
||||
ETransition * transition = nullptr /* 场景切换动画 */
|
||||
Transition * transition = nullptr /* 场景切换动画 */
|
||||
);
|
||||
|
||||
// 清空保存的所有场景
|
||||
static void clearScene();
|
||||
|
||||
// 获取当前场景
|
||||
static EScene * getCurrentScene();
|
||||
static Scene * getCurrentScene();
|
||||
|
||||
// 是否正在进行转场动画
|
||||
static bool isTransitioning();
|
||||
|
|
@ -81,57 +80,57 @@ private:
|
|||
|
||||
|
||||
// 定时器管理器
|
||||
class ETimerManager
|
||||
class TimerManager
|
||||
{
|
||||
friend EGame;
|
||||
friend ENode;
|
||||
friend Game;
|
||||
friend Node;
|
||||
|
||||
public:
|
||||
// 绑定定时器到场景
|
||||
static void bindTimer(
|
||||
ETimer * timer,
|
||||
EScene * pParentScene
|
||||
static void add(
|
||||
Timer * pTimer,
|
||||
Scene * pParentScene
|
||||
);
|
||||
|
||||
// 绑定定时器到节点
|
||||
static void bindTimer(
|
||||
ETimer * timer,
|
||||
ENode * pParentNode
|
||||
static void add(
|
||||
Timer * pTimer,
|
||||
Node * pParentNode
|
||||
);
|
||||
|
||||
// 启动具有相同名称的定时器
|
||||
static void startTimers(
|
||||
const EString &name
|
||||
const String &name
|
||||
);
|
||||
|
||||
// 停止具有相同名称的定时器
|
||||
static void stopTimers(
|
||||
const EString &name
|
||||
const String &name
|
||||
);
|
||||
|
||||
// 删除具有相同名称的定时器
|
||||
static void delTimers(
|
||||
const EString &name
|
||||
static void deleteTimers(
|
||||
const String &name
|
||||
);
|
||||
|
||||
// 启动绑定在场景及其子节点上的所有定时器
|
||||
static void startAllTimersBindedWith(
|
||||
EScene * pParentScene
|
||||
Scene * pParentScene
|
||||
);
|
||||
|
||||
// 停止绑定在场景及其子节点上的所有定时器
|
||||
static void stopAllTimersBindedWith(
|
||||
EScene * pParentScene
|
||||
Scene * pParentScene
|
||||
);
|
||||
|
||||
// 启动绑定在节点上的所有定时器
|
||||
static void startAllTimersBindedWith(
|
||||
ENode * pParentNode
|
||||
Node * pParentNode
|
||||
);
|
||||
|
||||
// 停止绑定在节点上的所有定时器
|
||||
static void stopAllTimersBindedWith(
|
||||
ENode * pParentNode
|
||||
Node * pParentNode
|
||||
);
|
||||
|
||||
// 启动所有定时器
|
||||
|
|
@ -146,7 +145,7 @@ private:
|
|||
|
||||
// 清空绑定在节点上的所有定时器
|
||||
static void __clearAllTimersBindedWith(
|
||||
ENode * pParentNode
|
||||
Node * pParentNode
|
||||
);
|
||||
|
||||
// 重置定时器状态
|
||||
|
|
@ -155,32 +154,26 @@ private:
|
|||
|
||||
|
||||
// 动作管理器
|
||||
class EActionManager
|
||||
class ActionManager
|
||||
{
|
||||
friend EGame;
|
||||
friend ENode;
|
||||
friend EAction;
|
||||
friend Game;
|
||||
friend Node;
|
||||
friend Action;
|
||||
|
||||
public:
|
||||
// 添加动作
|
||||
static void addAction(
|
||||
EAction * pAction,
|
||||
ENode * pTargetNode
|
||||
);
|
||||
|
||||
// 继续绑定在节点上的所有动作
|
||||
static void resumeAllActionsBindedWith(
|
||||
ENode * pTargetNode
|
||||
Node * pTargetNode
|
||||
);
|
||||
|
||||
// 暂停绑定在节点上的所有动作
|
||||
static void pauseAllActionsBindedWith(
|
||||
ENode * pTargetNode
|
||||
Node * pTargetNode
|
||||
);
|
||||
|
||||
// 停止绑定在节点上的所有动作
|
||||
static void stopAllActionsBindedWith(
|
||||
ENode * pTargetNode
|
||||
Node * pTargetNode
|
||||
);
|
||||
|
||||
// 继续所有动作
|
||||
|
|
@ -193,12 +186,18 @@ public:
|
|||
static void stopAllActions();
|
||||
|
||||
private:
|
||||
// 添加动作
|
||||
static void _add(
|
||||
Action * pAction,
|
||||
Node * pTargetNode
|
||||
);
|
||||
|
||||
// 更新动画状态
|
||||
static void __update();
|
||||
|
||||
// 清空绑定在节点上的所有动作
|
||||
static void __clearAllActionsBindedWith(
|
||||
ENode * pTargetNode
|
||||
Node * pTargetNode
|
||||
);
|
||||
|
||||
// 重置所有动作状态
|
||||
|
|
@ -207,19 +206,19 @@ private:
|
|||
|
||||
|
||||
// 音乐管理工具
|
||||
class EMusicManager
|
||||
class MusicManager
|
||||
{
|
||||
friend EGame;
|
||||
friend Game;
|
||||
|
||||
public:
|
||||
// 添加音乐文件
|
||||
static bool add(
|
||||
const EString & strFilePath /* 音乐文件路径 */
|
||||
const String & strFilePath /* 音乐文件路径 */
|
||||
);
|
||||
|
||||
// 获取指定音乐的 EMusic 对象
|
||||
static EMusic * get(
|
||||
const EString & strFilePath /* 音乐文件路径 */
|
||||
// 获取指定音乐的 Music 对象
|
||||
static Music * get(
|
||||
const String & strFilePath /* 音乐文件路径 */
|
||||
);
|
||||
|
||||
// 暂停所有音乐
|
||||
|
|
@ -246,26 +245,26 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class EShapeManager
|
||||
class ShapeManager
|
||||
{
|
||||
friend EGame;
|
||||
friend ENode;
|
||||
friend EShape;
|
||||
friend Game;
|
||||
friend Node;
|
||||
friend Shape;
|
||||
|
||||
private:
|
||||
// 更新形状
|
||||
static void __updateShape(
|
||||
EShape * pActiveShape
|
||||
Shape * pActiveShape
|
||||
);
|
||||
|
||||
// 添加形状
|
||||
static void __addShape(
|
||||
EShape * pShape
|
||||
Shape * pShape
|
||||
);
|
||||
|
||||
// 删除已绑定的形状
|
||||
static void __delShape(
|
||||
EShape * pShape
|
||||
Shape * pShape
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
333
core/enodes.h
333
core/enodes.h
|
|
@ -5,21 +5,21 @@ namespace e2d
|
|||
{
|
||||
|
||||
|
||||
class EAction;
|
||||
class EShape;
|
||||
class ETransition;
|
||||
class Action;
|
||||
class Shape;
|
||||
class Transition;
|
||||
|
||||
class ENode :
|
||||
public EObject
|
||||
class Node :
|
||||
public Obj
|
||||
{
|
||||
friend EScene;
|
||||
friend EShape;
|
||||
friend ETransition;
|
||||
friend Scene;
|
||||
friend Shape;
|
||||
friend Transition;
|
||||
|
||||
public:
|
||||
ENode();
|
||||
Node();
|
||||
|
||||
virtual ~ENode();
|
||||
virtual ~Node();
|
||||
|
||||
// 进入场景时执行
|
||||
virtual void onEnter() {}
|
||||
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
// 碰撞处理
|
||||
virtual void onCollide(
|
||||
ENode* pCollisionNode, /* 发生碰撞的节点 */
|
||||
Node* pCollisionNode, /* 发生碰撞的节点 */
|
||||
int nRelation /* 碰撞关系,取值为 ERelation::VALUE 中的一种 */
|
||||
) {}
|
||||
|
||||
|
|
@ -50,11 +50,11 @@ public:
|
|||
|
||||
// 判断点是否在节点内
|
||||
virtual bool isPointIn(
|
||||
EPoint point
|
||||
Point point
|
||||
);
|
||||
|
||||
// 获取节点名称
|
||||
virtual EString getName() const;
|
||||
virtual String getName() const;
|
||||
|
||||
// 获取节点绘图顺序
|
||||
virtual int getOrder() const;
|
||||
|
|
@ -66,7 +66,7 @@ public:
|
|||
virtual float getPosY() const;
|
||||
|
||||
// 获取节点坐标
|
||||
virtual EPoint getPos() const;
|
||||
virtual Point getPos() const;
|
||||
|
||||
// 获取节点宽度
|
||||
virtual float getWidth() const;
|
||||
|
|
@ -81,7 +81,7 @@ public:
|
|||
virtual float getRealHeight() const;
|
||||
|
||||
// 获取节点大小(不考虑缩放)
|
||||
virtual ESize getRealSize() const;
|
||||
virtual Size getRealSize() const;
|
||||
|
||||
// 获取节点的中心点
|
||||
virtual float getPivotX() const;
|
||||
|
|
@ -90,7 +90,7 @@ public:
|
|||
virtual float getPivotY() const;
|
||||
|
||||
// 获取节点大小
|
||||
virtual ESize getSize() const;
|
||||
virtual Size getSize() const;
|
||||
|
||||
// 获取节点横向缩放比例
|
||||
virtual float getScaleX() const;
|
||||
|
|
@ -111,38 +111,38 @@ public:
|
|||
virtual float getOpacity() const;
|
||||
|
||||
// 获取节点形状
|
||||
virtual EShape * getShape() const;
|
||||
virtual Shape * getShape() const;
|
||||
|
||||
// 获取父节点
|
||||
virtual ENode * getParent() const;
|
||||
virtual Node * getParent() const;
|
||||
|
||||
// 获取节点所在场景
|
||||
virtual EScene * getParentScene() const;
|
||||
virtual Scene * getParentScene() const;
|
||||
|
||||
// 获取名称相同的子节点
|
||||
virtual ENode * getChild(
|
||||
const EString & name
|
||||
virtual Node * getChild(
|
||||
const String & name
|
||||
);
|
||||
|
||||
// 获取所有名称相同的子节点
|
||||
virtual std::vector<ENode*> getChildren(
|
||||
const EString & name
|
||||
virtual std::vector<Node*> getChildren(
|
||||
const String & name
|
||||
);
|
||||
|
||||
// 获取所有子节点
|
||||
virtual std::vector<ENode*> &getChildren();
|
||||
virtual std::vector<Node*> &getChildren();
|
||||
|
||||
// 获取子节点数量
|
||||
virtual int getChildrenCount() const;
|
||||
|
||||
// 移除子节点
|
||||
virtual bool removeChild(
|
||||
ENode * child
|
||||
Node * child
|
||||
);
|
||||
|
||||
// 移除所有名称相同的子节点
|
||||
virtual void removeChildren(
|
||||
const EString & childName
|
||||
const String & childName
|
||||
);
|
||||
|
||||
// 从父节点移除
|
||||
|
|
@ -163,7 +163,7 @@ public:
|
|||
|
||||
// 设置节点名称
|
||||
virtual void setName(
|
||||
const EString & name
|
||||
const String & name
|
||||
);
|
||||
|
||||
// 设置节点横坐标
|
||||
|
|
@ -178,7 +178,7 @@ public:
|
|||
|
||||
// 设置节点坐标
|
||||
virtual void setPos(
|
||||
const EPoint & point
|
||||
const Point & point
|
||||
);
|
||||
|
||||
// 设置节点坐标
|
||||
|
|
@ -205,7 +205,7 @@ public:
|
|||
|
||||
// 移动节点
|
||||
virtual void movePos(
|
||||
const EVector2 & v
|
||||
const Vector & v
|
||||
);
|
||||
|
||||
// 设置节点绘图顺序
|
||||
|
|
@ -291,33 +291,33 @@ public:
|
|||
|
||||
// 设置节点形状
|
||||
virtual void setShape(
|
||||
EShape * pShape
|
||||
Shape * pShape
|
||||
);
|
||||
|
||||
// 添加子节点
|
||||
virtual void addChild(
|
||||
ENode * child,
|
||||
Node * child,
|
||||
int order = 0
|
||||
);
|
||||
|
||||
// 执行动画
|
||||
virtual void runAction(
|
||||
EAction * action
|
||||
Action * action
|
||||
);
|
||||
|
||||
// 继续动画
|
||||
virtual void resumeAction(
|
||||
EAction * action
|
||||
Action * action
|
||||
);
|
||||
|
||||
// 暂停动画
|
||||
virtual void pauseAction(
|
||||
EAction * action
|
||||
Action * action
|
||||
);
|
||||
|
||||
// 停止动画
|
||||
virtual void stopAction(
|
||||
EAction * action
|
||||
Action * action
|
||||
);
|
||||
|
||||
// 继续所有暂停动画
|
||||
|
|
@ -353,7 +353,7 @@ protected:
|
|||
|
||||
// 设置节点所在场景
|
||||
void _setParentScene(
|
||||
EScene * scene
|
||||
Scene * scene
|
||||
);
|
||||
|
||||
// 对自身进行二维矩阵变换
|
||||
|
|
@ -372,16 +372,16 @@ protected:
|
|||
);
|
||||
|
||||
// 更新节点二维矩阵
|
||||
static void _updateTransform(ENode * node);
|
||||
static void _updateTransform(Node * node);
|
||||
|
||||
// 更新节点透明度
|
||||
static void _updateOpacity(ENode * node);
|
||||
static void _updateOpacity(Node * node);
|
||||
|
||||
protected:
|
||||
EString m_sName;
|
||||
String m_sName;
|
||||
size_t m_nHashName;
|
||||
EPoint m_Pos;
|
||||
ESize m_Size;
|
||||
Point m_Pos;
|
||||
Size m_Size;
|
||||
float m_fScaleX;
|
||||
float m_fScaleY;
|
||||
float m_fRotation;
|
||||
|
|
@ -397,34 +397,34 @@ protected:
|
|||
bool m_bDisplayedInScene;
|
||||
bool m_bSortChildrenNeeded;
|
||||
bool m_bTransformNeeded;
|
||||
EShape * m_pShape;
|
||||
EScene * m_pParentScene;
|
||||
ENode * m_pParent;
|
||||
Shape * m_pShape;
|
||||
Scene * m_pParentScene;
|
||||
Node * m_pParent;
|
||||
D2D1::Matrix3x2F m_MatriInitial;
|
||||
D2D1::Matrix3x2F m_MatriFinal;
|
||||
std::vector<ENode*> m_vChildren;
|
||||
std::vector<Node*> m_vChildren;
|
||||
};
|
||||
|
||||
|
||||
class ESprite :
|
||||
public ENode
|
||||
class Sprite :
|
||||
public Node
|
||||
{
|
||||
public:
|
||||
// 创建一个空精灵
|
||||
ESprite();
|
||||
Sprite();
|
||||
|
||||
// 从 EImage 对象创建精灵
|
||||
ESprite(
|
||||
EImage * image
|
||||
Sprite(
|
||||
Image * image
|
||||
);
|
||||
|
||||
// 从文件图片创建精灵
|
||||
ESprite(
|
||||
Sprite(
|
||||
LPCTSTR imageFileName
|
||||
);
|
||||
|
||||
// 从文件图片创建精灵并裁剪
|
||||
ESprite(
|
||||
Sprite(
|
||||
LPCTSTR imageFileName,
|
||||
float x,
|
||||
float y,
|
||||
|
|
@ -432,11 +432,11 @@ public:
|
|||
float height
|
||||
);
|
||||
|
||||
virtual ~ESprite();
|
||||
virtual ~Sprite();
|
||||
|
||||
// 加载精灵图片
|
||||
virtual void loadFrom(
|
||||
EImage * texture
|
||||
Image * texture
|
||||
);
|
||||
|
||||
// 从本地文件加载图片
|
||||
|
|
@ -453,48 +453,48 @@ public:
|
|||
);
|
||||
|
||||
// 获取 EImage 对象
|
||||
virtual EImage * getImage() const;
|
||||
virtual Image * getImage() const;
|
||||
|
||||
// 渲染精灵
|
||||
virtual void onRender() override;
|
||||
|
||||
protected:
|
||||
EImage * m_pImage;
|
||||
Image * m_pImage;
|
||||
};
|
||||
|
||||
|
||||
class EText :
|
||||
public ENode
|
||||
class Text :
|
||||
public Node
|
||||
{
|
||||
public:
|
||||
EText();
|
||||
Text();
|
||||
|
||||
EText(
|
||||
const EString & text
|
||||
Text(
|
||||
const String & text
|
||||
);
|
||||
|
||||
EText(
|
||||
EFont * font
|
||||
Text(
|
||||
Font * font
|
||||
);
|
||||
|
||||
EText(
|
||||
const EString & text,
|
||||
EFont * font
|
||||
Text(
|
||||
const String & text,
|
||||
Font * font
|
||||
);
|
||||
|
||||
EText(
|
||||
const EString & text,
|
||||
EString fontFamily,
|
||||
Text(
|
||||
const String & text,
|
||||
String fontFamily,
|
||||
float fontSize = 22,
|
||||
UINT32 color = EColor::WHITE,
|
||||
UINT32 fontWeight = EFontWeight::REGULAR,
|
||||
UINT32 color = Color::WHITE,
|
||||
UINT32 fontWeight = FontWeight::REGULAR,
|
||||
bool italic = false
|
||||
);
|
||||
|
||||
virtual ~EText();
|
||||
virtual ~Text();
|
||||
|
||||
// 获取文本
|
||||
EString getText() const;
|
||||
String getText() const;
|
||||
|
||||
// 获取文本宽度
|
||||
virtual float getWidth() const override;
|
||||
|
|
@ -503,16 +503,16 @@ public:
|
|||
virtual float getRealWidth() const override;
|
||||
|
||||
// 获取字体
|
||||
EFont * getFont() const;
|
||||
Font * getFont() const;
|
||||
|
||||
// 设置文本
|
||||
void setText(
|
||||
const EString & text
|
||||
const String & text
|
||||
);
|
||||
|
||||
// 设置字体
|
||||
void setFont(
|
||||
EFont * font
|
||||
Font * font
|
||||
);
|
||||
|
||||
// 设置文字自动换行
|
||||
|
|
@ -533,48 +533,48 @@ protected:
|
|||
void _initTextLayout();
|
||||
|
||||
protected:
|
||||
EString m_sText;
|
||||
String m_sText;
|
||||
bool m_bWordWrapping;
|
||||
float m_fWordWrappingWidth;
|
||||
EFont * m_pFont;
|
||||
Font * m_pFont;
|
||||
};
|
||||
|
||||
|
||||
class EButton :
|
||||
public ENode
|
||||
class Button :
|
||||
public Node
|
||||
{
|
||||
public:
|
||||
// 创建一个空按钮
|
||||
EButton();
|
||||
Button();
|
||||
|
||||
// 创建按钮
|
||||
EButton(
|
||||
ENode * normal, /* 普通状态 */
|
||||
const BtnClkCallback & callback = nullptr
|
||||
Button(
|
||||
Node * normal, /* 普通状态 */
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建按钮
|
||||
EButton(
|
||||
ENode * normal, /* 普通状态 */
|
||||
ENode * selected, /* 鼠标按下状态 */
|
||||
const BtnClkCallback & callback = nullptr
|
||||
Button(
|
||||
Node * normal, /* 普通状态 */
|
||||
Node * selected, /* 鼠标按下状态 */
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建按钮
|
||||
EButton(
|
||||
ENode * normal, /* 普通状态 */
|
||||
ENode * mouseover, /* 鼠标移入状态 */
|
||||
ENode * selected, /* 鼠标按下状态 */
|
||||
const BtnClkCallback & callback = nullptr
|
||||
Button(
|
||||
Node * normal, /* 普通状态 */
|
||||
Node * mouseover, /* 鼠标移入状态 */
|
||||
Node * selected, /* 鼠标按下状态 */
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建按钮
|
||||
EButton(
|
||||
ENode * normal, /* 普通状态 */
|
||||
ENode * mouseover, /* 鼠标移入状态 */
|
||||
ENode * selected, /* 鼠标移入状态 */
|
||||
ENode * disabled, /* 按钮禁用状态 */
|
||||
const BtnClkCallback & callback = nullptr
|
||||
Button(
|
||||
Node * normal, /* 普通状态 */
|
||||
Node * mouseover, /* 鼠标移入状态 */
|
||||
Node * selected, /* 鼠标移入状态 */
|
||||
Node * disabled, /* 按钮禁用状态 */
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 获取按钮状态是启用还是禁用
|
||||
|
|
@ -587,27 +587,27 @@ public:
|
|||
|
||||
// 设置一般情况下显示的按钮
|
||||
virtual void setNormal(
|
||||
ENode * normal
|
||||
Node * normal
|
||||
);
|
||||
|
||||
// 设置鼠标移入按钮时显示的按钮
|
||||
virtual void setMouseOver(
|
||||
ENode * mouseover
|
||||
Node * mouseover
|
||||
);
|
||||
|
||||
// 设置鼠标选中按钮时显示的按钮
|
||||
virtual void setSelected(
|
||||
ENode * selected
|
||||
Node * selected
|
||||
);
|
||||
|
||||
// 设置按钮被禁用时显示的按钮
|
||||
virtual void setDisabled(
|
||||
ENode * disabled
|
||||
Node * disabled
|
||||
);
|
||||
|
||||
// 设置回调函数
|
||||
void setCallback(
|
||||
const BtnClkCallback & callback
|
||||
const ButtonCallback & callback
|
||||
);
|
||||
|
||||
// 设置中心点的横向位置
|
||||
|
|
@ -645,68 +645,65 @@ protected:
|
|||
virtual void _runCallback();
|
||||
|
||||
protected:
|
||||
ENode * m_pNormal;
|
||||
ENode * m_pMouseover;
|
||||
ENode * m_pSelected;
|
||||
ENode * m_pDisabled;
|
||||
Node * m_pNormal;
|
||||
Node * m_pMouseover;
|
||||
Node * m_pSelected;
|
||||
Node * m_pDisabled;
|
||||
bool m_bEnable;
|
||||
bool m_bIsSelected;
|
||||
BTN_STATE m_eBtnState;
|
||||
BtnClkCallback m_Callback;
|
||||
ButtonCallback m_Callback;
|
||||
};
|
||||
|
||||
|
||||
class EButtonToggle :
|
||||
public EButton
|
||||
class ButtonToggle :
|
||||
public Button
|
||||
{
|
||||
public:
|
||||
// 创建一个空的开关按钮
|
||||
EButtonToggle();
|
||||
ButtonToggle();
|
||||
|
||||
// 创建开关按钮
|
||||
EButtonToggle(
|
||||
ENode * onNormal,
|
||||
ENode * offNormal,
|
||||
const BtnClkCallback & callback = nullptr
|
||||
ButtonToggle(
|
||||
Node * onNormal,
|
||||
Node * offNormal,
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建开关按钮
|
||||
EButtonToggle(
|
||||
ENode * onNormal,
|
||||
ENode * offNormal,
|
||||
ENode * onSelected,
|
||||
ENode * offSelected,
|
||||
const BtnClkCallback & callback = nullptr
|
||||
ButtonToggle(
|
||||
Node * onNormal,
|
||||
Node * offNormal,
|
||||
Node * onSelected,
|
||||
Node * offSelected,
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建开关按钮
|
||||
EButtonToggle(
|
||||
ENode * onNormal,
|
||||
ENode * offNormal,
|
||||
ENode * onMouseOver,
|
||||
ENode * offMouseOver,
|
||||
ENode * onSelected,
|
||||
ENode * offSelected,
|
||||
const BtnClkCallback & callback = nullptr
|
||||
ButtonToggle(
|
||||
Node * onNormal,
|
||||
Node * offNormal,
|
||||
Node * onMouseOver,
|
||||
Node * offMouseOver,
|
||||
Node * onSelected,
|
||||
Node * offSelected,
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 创建开关按钮
|
||||
EButtonToggle(
|
||||
ENode * onNormal,
|
||||
ENode * offNormal,
|
||||
ENode * onMouseOver,
|
||||
ENode * offMouseOver,
|
||||
ENode * onSelected,
|
||||
ENode * offSelected,
|
||||
ENode * onDisabled,
|
||||
ENode * offDisabled,
|
||||
const BtnClkCallback & callback = nullptr
|
||||
ButtonToggle(
|
||||
Node * onNormal,
|
||||
Node * offNormal,
|
||||
Node * onMouseOver,
|
||||
Node * offMouseOver,
|
||||
Node * onSelected,
|
||||
Node * offSelected,
|
||||
Node * onDisabled,
|
||||
Node * offDisabled,
|
||||
const ButtonCallback & callback = nullptr
|
||||
);
|
||||
|
||||
// 切换开关状态(执行回调函数)
|
||||
void toggle();
|
||||
|
||||
// 获取开关状态
|
||||
// 获取开关状态(打开或关闭)
|
||||
bool getState() const;
|
||||
|
||||
// 设置开关按钮的状态(打开或关闭)
|
||||
|
|
@ -716,42 +713,42 @@ public:
|
|||
|
||||
// 设置按钮打开状态下显示的按钮
|
||||
virtual void setNormal(
|
||||
ENode * normal
|
||||
Node * normal
|
||||
) override;
|
||||
|
||||
// 设置按钮打开状态下,鼠标移入按钮时显示的按钮
|
||||
virtual void setMouseOver(
|
||||
ENode * mouseover
|
||||
Node * mouseover
|
||||
) override;
|
||||
|
||||
// 设置按钮打开状态下,鼠标选中按钮时显示的按钮
|
||||
virtual void setSelected(
|
||||
ENode * selected
|
||||
Node * selected
|
||||
) override;
|
||||
|
||||
// 设置按钮打开状态下,被禁用时显示的按钮
|
||||
virtual void setDisabled(
|
||||
ENode * disabled
|
||||
Node * disabled
|
||||
) override;
|
||||
|
||||
// 设置按钮关闭状态下显示的按钮
|
||||
void setNormalOff(
|
||||
ENode * normal
|
||||
Node * normal
|
||||
);
|
||||
|
||||
// 设置按钮关闭状态下,鼠标移入按钮时显示的按钮
|
||||
void setMouseOverOff(
|
||||
ENode * mouseover
|
||||
Node * mouseover
|
||||
);
|
||||
|
||||
// 设置按钮关闭状态下,鼠标选中按钮时显示的按钮
|
||||
void setSelectedOff(
|
||||
ENode * selected
|
||||
Node * selected
|
||||
);
|
||||
|
||||
// 设置按钮关闭状态下,按钮被禁用时显示的按钮
|
||||
void setDisabledOff(
|
||||
ENode * disabled
|
||||
Node * disabled
|
||||
);
|
||||
|
||||
// 设置中心点的横向位置
|
||||
|
|
@ -781,29 +778,29 @@ protected:
|
|||
virtual void _runCallback() override;
|
||||
|
||||
protected:
|
||||
ENode * m_pNormalOn;
|
||||
ENode * m_pNormalOff;
|
||||
ENode * m_pMouseoverOn;
|
||||
ENode * m_pMouseoverOff;
|
||||
ENode * m_pSelectedOn;
|
||||
ENode * m_pSelectedOff;
|
||||
ENode * m_pDisabledOn;
|
||||
ENode * m_pDisabledOff;
|
||||
Node * m_pNormalOn;
|
||||
Node * m_pNormalOff;
|
||||
Node * m_pMouseoverOn;
|
||||
Node * m_pMouseoverOff;
|
||||
Node * m_pSelectedOn;
|
||||
Node * m_pSelectedOff;
|
||||
Node * m_pDisabledOn;
|
||||
Node * m_pDisabledOff;
|
||||
bool m_bState;
|
||||
};
|
||||
|
||||
|
||||
class EMenu :
|
||||
public ENode
|
||||
class Menu :
|
||||
public Node
|
||||
{
|
||||
public:
|
||||
// 创建空菜单
|
||||
EMenu();
|
||||
Menu();
|
||||
|
||||
// 创建菜单
|
||||
EMenu(
|
||||
Menu(
|
||||
int number, /* 菜单中按钮的数量 */
|
||||
EButton * button1, /* 第一个按钮 */
|
||||
Button * button1, /* 第一个按钮 */
|
||||
...
|
||||
);
|
||||
|
||||
|
|
@ -820,17 +817,17 @@ public:
|
|||
|
||||
// 添加按钮
|
||||
void addButton(
|
||||
EButton * button
|
||||
Button * button
|
||||
);
|
||||
|
||||
// 移除按钮
|
||||
bool removeButton(
|
||||
EButton * button
|
||||
Button * button
|
||||
);
|
||||
|
||||
protected:
|
||||
bool m_bEnable;
|
||||
std::vector<EButton*> m_vButtons;
|
||||
std::vector<Button*> m_vButtons;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -5,28 +5,28 @@
|
|||
namespace e2d
|
||||
{
|
||||
|
||||
class EShapeManager;
|
||||
class ENode;
|
||||
class ShapeManager;
|
||||
class Node;
|
||||
|
||||
|
||||
class EShape :
|
||||
public EObject
|
||||
class Shape :
|
||||
public Obj
|
||||
{
|
||||
friend EShapeManager;
|
||||
friend ENode;
|
||||
friend ShapeManager;
|
||||
friend Node;
|
||||
|
||||
public:
|
||||
EShape();
|
||||
Shape();
|
||||
|
||||
virtual ~EShape();
|
||||
virtual ~Shape();
|
||||
|
||||
// 判断两形状的交集关系
|
||||
virtual int getRelationWith(
|
||||
EShape * pShape
|
||||
Shape * pShape
|
||||
) const;
|
||||
|
||||
// 获取父节点
|
||||
ENode * getParentNode() const;
|
||||
Node * getParentNode() const;
|
||||
|
||||
// 获取类别掩码
|
||||
UINT32 getCategoryBitmask() const;
|
||||
|
|
@ -81,20 +81,20 @@ protected:
|
|||
UINT32 m_nCollisionBitmask;
|
||||
UINT32 m_nColor;
|
||||
float m_fOpacity;
|
||||
ENode * m_pParentNode;
|
||||
Node * m_pParentNode;
|
||||
ID2D1TransformedGeometry * m_pTransformedShape;
|
||||
};
|
||||
|
||||
|
||||
class ERectangle :
|
||||
public EShape
|
||||
class Rect :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个空矩形
|
||||
ERectangle();
|
||||
Rect();
|
||||
|
||||
// 根据左上角坐标和宽高创建矩形
|
||||
ERectangle(
|
||||
Rect(
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
|
|
@ -102,11 +102,11 @@ public:
|
|||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的矩形
|
||||
ERectangle(
|
||||
ENode * node
|
||||
Rect(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~ERectangle();
|
||||
virtual ~Rect();
|
||||
|
||||
protected:
|
||||
void _setRect(
|
||||
|
|
@ -123,29 +123,29 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ECircle :
|
||||
public EShape
|
||||
class Circle :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个空的圆形
|
||||
ECircle();
|
||||
Circle();
|
||||
|
||||
// 根据圆心和半径创建圆形
|
||||
ECircle(
|
||||
EPoint center,
|
||||
Circle(
|
||||
Point center,
|
||||
float radius
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的圆形
|
||||
ECircle(
|
||||
ENode * node
|
||||
Circle(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~ECircle();
|
||||
virtual ~Circle();
|
||||
|
||||
protected:
|
||||
void _setCircle(
|
||||
EPoint center,
|
||||
Point center,
|
||||
float radius
|
||||
);
|
||||
|
||||
|
|
@ -156,30 +156,30 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EEllipse :
|
||||
public EShape
|
||||
class Ellipse :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个空的椭圆
|
||||
EEllipse();
|
||||
Ellipse();
|
||||
|
||||
// 根据圆心和半径创建椭圆
|
||||
EEllipse(
|
||||
EPoint center,
|
||||
Ellipse(
|
||||
Point center,
|
||||
float radiusX,
|
||||
float radiusY
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的椭圆
|
||||
EEllipse(
|
||||
ENode * node
|
||||
Ellipse(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~EEllipse();
|
||||
virtual ~Ellipse();
|
||||
|
||||
protected:
|
||||
void _setEllipse(
|
||||
EPoint center,
|
||||
Point center,
|
||||
float radiusX,
|
||||
float radiusY
|
||||
);
|
||||
|
|
|
|||
120
core/etools.h
120
core/etools.h
|
|
@ -5,25 +5,25 @@
|
|||
namespace e2d
|
||||
{
|
||||
|
||||
class ETimerManager;
|
||||
class EMusicManager;
|
||||
class TimerManager;
|
||||
class MusicManager;
|
||||
|
||||
// 随机数产生器
|
||||
class ERandom
|
||||
class Random
|
||||
{
|
||||
public:
|
||||
// 取得整型范围内的一个随机数
|
||||
template<typename T>
|
||||
static inline T range(T min, T max) { return e2d::ERandom::randomInt(min, max); }
|
||||
static inline T range(T min, T max) { return e2d::Random::randomInt(min, max); }
|
||||
|
||||
// 取得浮点数范围内的一个随机数
|
||||
static inline float range(float min, float max) { return e2d::ERandom::randomReal(min, max); }
|
||||
static inline float range(float min, float max) { return e2d::Random::randomReal(min, max); }
|
||||
|
||||
// 取得浮点数范围内的一个随机数
|
||||
static inline double range(double min, double max) { return e2d::ERandom::randomReal(min, max); }
|
||||
static inline double range(double min, double max) { return e2d::Random::randomReal(min, max); }
|
||||
|
||||
// 取得浮点数范围内的一个随机数
|
||||
static inline long double range(long double min, long double max) { return e2d::ERandom::randomReal(min, max); }
|
||||
static inline long double range(long double min, long double max) { return e2d::Random::randomReal(min, max); }
|
||||
|
||||
// 取得整型范围内的一个随机数
|
||||
template<typename T>
|
||||
|
|
@ -51,31 +51,28 @@ public:
|
|||
|
||||
|
||||
// 定时器
|
||||
class ETimer :
|
||||
public EObject
|
||||
class Timer :
|
||||
public Obj
|
||||
{
|
||||
friend ETimerManager;
|
||||
friend TimerManager;
|
||||
|
||||
public:
|
||||
ETimer();
|
||||
Timer();
|
||||
|
||||
ETimer(
|
||||
Timer(
|
||||
const TimerCallback &callback, /* 定时器回调函数 */
|
||||
int repeatTimes = -1, /* 定时器执行次数 */
|
||||
float interval = 0LL, /* 时间间隔(秒) */
|
||||
bool atOnce = false /* 是否立即执行 */
|
||||
);
|
||||
|
||||
ETimer(
|
||||
const EString &name, /* 定时器名称 */
|
||||
const TimerCallback &callback, /* 定时器回调函数 */
|
||||
int repeatTimes = -1, /* 定时器执行次数 */
|
||||
float interval = 0, /* 时间间隔(秒) */
|
||||
int repeatTimes = -1, /* 定时器执行次数 */
|
||||
bool atOnce = false /* 是否立即执行 */
|
||||
);
|
||||
|
||||
// 获取定时器状态
|
||||
bool isRunning() const;
|
||||
Timer(
|
||||
const String &name, /* 定时器名称 */
|
||||
const TimerCallback &callback, /* 定时器回调函数 */
|
||||
float interval = 0, /* 时间间隔(秒) */
|
||||
int repeatTimes = -1, /* 定时器执行次数 */
|
||||
bool atOnce = false /* 是否立即执行 */
|
||||
);
|
||||
|
||||
// 启动定时器
|
||||
void start();
|
||||
|
|
@ -83,15 +80,18 @@ public:
|
|||
// 停止定时器
|
||||
void stop();
|
||||
|
||||
// 获取定时器状态
|
||||
bool isRunning() const;
|
||||
|
||||
// 获取定时器名称
|
||||
EString getName() const;
|
||||
String getName() const;
|
||||
|
||||
// 获取定时器所在节点
|
||||
ENode * getParentNode() const;
|
||||
Node * getParentNode() const;
|
||||
|
||||
// 设置定时器名称
|
||||
void setName(
|
||||
const EString &name
|
||||
const String &name
|
||||
);
|
||||
|
||||
// 设置定时器执行间隔(秒)
|
||||
|
|
@ -114,111 +114,101 @@ public:
|
|||
bool bAtOnce
|
||||
);
|
||||
|
||||
// 绑定定时器到场景
|
||||
virtual void bindWith(
|
||||
EScene * pParentScene
|
||||
);
|
||||
|
||||
// 绑定定时器到节点
|
||||
virtual void bindWith(
|
||||
ENode * pParentNode
|
||||
);
|
||||
|
||||
protected:
|
||||
// 执行回调函数
|
||||
virtual void _callOn();
|
||||
void _callOn();
|
||||
|
||||
// 判断是否达到执行状态
|
||||
bool _isReady();
|
||||
bool _isReady() const;
|
||||
|
||||
protected:
|
||||
EString m_sName;
|
||||
String m_sName;
|
||||
bool m_bRunning;
|
||||
bool m_bAtOnce;
|
||||
int m_nRunTimes;
|
||||
int m_nRepeatTimes;
|
||||
float m_fInterval;
|
||||
float m_fLast;
|
||||
ENode * m_pParentNode;
|
||||
Node * m_pParentNode;
|
||||
TimerCallback m_Callback;
|
||||
};
|
||||
|
||||
|
||||
// 数据管理工具
|
||||
class EData
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
// 保存 int 类型的值
|
||||
static void saveInt(
|
||||
const EString & key,
|
||||
const String & key,
|
||||
int value
|
||||
);
|
||||
|
||||
// 保存 float 类型的值
|
||||
static void saveFloat(
|
||||
const EString & key,
|
||||
const String & key,
|
||||
float value
|
||||
);
|
||||
|
||||
// 保存 字符串 类型的值
|
||||
static void saveString(
|
||||
const EString & key,
|
||||
const EString & value
|
||||
const String & key,
|
||||
const String & value
|
||||
);
|
||||
|
||||
// 获取 int 类型的值
|
||||
// (若不存在则返回 defaultValue 参数的值)
|
||||
static int getInt(
|
||||
const EString & key,
|
||||
const String & key,
|
||||
int defaultValue
|
||||
);
|
||||
|
||||
// 获取 float 类型的值
|
||||
// (若不存在则返回 defaultValue 参数的值)
|
||||
static float getFloat(
|
||||
const EString & key,
|
||||
const String & key,
|
||||
float defaultValue
|
||||
);
|
||||
|
||||
// 获取 字符串 类型的值
|
||||
// (若不存在则返回 defaultValue 参数的值)
|
||||
static EString getString(
|
||||
const EString & key,
|
||||
const EString & defaultValue
|
||||
static String getString(
|
||||
const String & key,
|
||||
const String & defaultValue
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// 文件管理工具
|
||||
class EFile
|
||||
class File
|
||||
{
|
||||
public:
|
||||
// 获取系统的 AppData Local 路径
|
||||
static EString getLocalAppDataPath();
|
||||
static String getLocalAppDataPath();
|
||||
|
||||
// 获取临时文件目录
|
||||
static EString getTempPath();
|
||||
static String getTempPath();
|
||||
|
||||
// 获取默认的保存路径
|
||||
static EString getDefaultSavePath();
|
||||
static String getDefaultSavePath();
|
||||
|
||||
// 获取文件扩展名
|
||||
static EString getFileExtension(
|
||||
const EString & filePath
|
||||
static String getFileExtension(
|
||||
const String & filePath
|
||||
);
|
||||
|
||||
// 打开保存文件对话框
|
||||
static EString getSaveFilePath(
|
||||
const EString & title = L"保存到", /* 对话框标题 */
|
||||
const EString & defExt = L"" /* 默认扩展名 */
|
||||
static String getSaveFilePath(
|
||||
const String & title = L"保存到", /* 对话框标题 */
|
||||
const String & defExt = L"" /* 默认扩展名 */
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// 音乐播放器
|
||||
class EMusic
|
||||
class Music
|
||||
{
|
||||
friend EMusicManager;
|
||||
friend MusicManager;
|
||||
|
||||
public:
|
||||
// 播放
|
||||
|
|
@ -258,13 +248,9 @@ public:
|
|||
IXAudio2SourceVoice* getIXAudio2SourceVoice() const;
|
||||
|
||||
protected:
|
||||
EMusic();
|
||||
Music();
|
||||
|
||||
virtual ~EMusic();
|
||||
|
||||
EMusic(const EMusic &) = delete;
|
||||
|
||||
EMusic &operator =(const EMusic &) = delete;
|
||||
virtual ~Music();
|
||||
|
||||
bool _open(LPWSTR strFileName);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ namespace e2d
|
|||
{
|
||||
|
||||
|
||||
class ESceneManager;
|
||||
class SceneManager;
|
||||
|
||||
class ETransition :
|
||||
public EObject
|
||||
class Transition :
|
||||
public Obj
|
||||
{
|
||||
friend ESceneManager;
|
||||
friend SceneManager;
|
||||
|
||||
public:
|
||||
ETransition(float duration);
|
||||
Transition(float duration);
|
||||
|
||||
// 场景切换动画是否结束
|
||||
bool isEnding();
|
||||
|
|
@ -36,8 +36,8 @@ protected:
|
|||
|
||||
// 保存当前场景和下一场景的指针
|
||||
void _setTarget(
|
||||
EScene * prev,
|
||||
EScene * next
|
||||
Scene * prev,
|
||||
Scene * next
|
||||
);
|
||||
|
||||
protected:
|
||||
|
|
@ -45,17 +45,17 @@ protected:
|
|||
float m_fLast;
|
||||
float m_fDuration;
|
||||
float m_fRateOfProgress;
|
||||
EScene * m_pPrevScene;
|
||||
EScene * m_pNextScene;
|
||||
Scene * m_pPrevScene;
|
||||
Scene * m_pNextScene;
|
||||
};
|
||||
|
||||
|
||||
class ETransitionFade :
|
||||
public ETransition
|
||||
class TransitionFade :
|
||||
public Transition
|
||||
{
|
||||
public:
|
||||
// 创建淡入淡出式的场景切换动画
|
||||
ETransitionFade(
|
||||
TransitionFade(
|
||||
float fadeOutDuration, /* 前一场景淡出动画持续时长 */
|
||||
float fadeInDuration /* 后一场景淡入动画持续时长 */
|
||||
);
|
||||
|
|
@ -75,12 +75,12 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ETransitionEmerge :
|
||||
public ETransition
|
||||
class TransitionEmerge :
|
||||
public Transition
|
||||
{
|
||||
public:
|
||||
// 创建浮现式的场景切换动画
|
||||
ETransitionEmerge(
|
||||
TransitionEmerge(
|
||||
float duration /* 浮现动画持续时长 */
|
||||
);
|
||||
|
||||
|
|
@ -94,8 +94,8 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ETransitionMove :
|
||||
public ETransition
|
||||
class TransitionMove :
|
||||
public Transition
|
||||
{
|
||||
public:
|
||||
enum MOVE_DIRECT
|
||||
|
|
@ -107,7 +107,7 @@ public:
|
|||
};
|
||||
|
||||
// 创建移动式的场景切换动画
|
||||
ETransitionMove(
|
||||
TransitionMove(
|
||||
float moveDuration, /* 场景移动动画持续时长 */
|
||||
MOVE_DIRECT direct = LEFT /* 场景移动方向 */
|
||||
);
|
||||
|
|
@ -122,8 +122,8 @@ protected:
|
|||
|
||||
protected:
|
||||
MOVE_DIRECT m_Direct;
|
||||
EVector2 m_Vec;
|
||||
EPoint m_NextPos;
|
||||
Vector m_Vec;
|
||||
Point m_NextPos;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -45,7 +45,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionScaleTo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionSequence.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\Animation.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Game.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Input.cpp" />
|
||||
|
|
@ -71,7 +70,7 @@
|
|||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
||||
|
|
|
|||
|
|
@ -83,9 +83,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\Animation.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -179,9 +176,6 @@
|
|||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -194,5 +188,8 @@
|
|||
<ClCompile Include="..\..\core\Tool\File.cpp">
|
||||
<Filter>Tool</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -184,7 +184,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionScaleTo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionSequence.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\Animation.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Game.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Input.cpp" />
|
||||
|
|
@ -210,7 +209,7 @@
|
|||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
||||
|
|
|
|||
|
|
@ -84,9 +84,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\Animation.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -180,9 +177,6 @@
|
|||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -195,5 +189,8 @@
|
|||
<ClCompile Include="..\..\core\Manager\MusicManager.cpp">
|
||||
<Filter>Manager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
|
@ -205,7 +205,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionScaleTo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionSequence.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp" />
|
||||
<ClCompile Include="..\..\core\Action\ActionGradual.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Game.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Input.cpp" />
|
||||
|
|
@ -231,7 +230,7 @@
|
|||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
||||
|
|
|
|||
|
|
@ -90,9 +90,6 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionTwo.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\ActionTwoAtSameTime.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Action\Animation.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -177,10 +174,10 @@
|
|||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\Shape.cpp">
|
||||
<ClCompile Include="..\..\core\Shape\Rect.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue