细节调整

This commit is contained in:
Nomango 2018-05-08 11:37:11 +08:00
parent 718b1b1a1a
commit a18ff4295d
24 changed files with 169 additions and 226 deletions

View File

@ -75,19 +75,19 @@ e2d::ActionLoop * e2d::Action::Loop(ActionBase * action, int times)
return new (std::nothrow) ActionLoop(action, times);
}
e2d::ActionFunc * e2d::Action::Func(Function func)
e2d::ActionFunc * e2d::Action::Func(const Function& func)
{
return new (std::nothrow) ActionFunc(func);
}
#ifdef HIGHER_THAN_VS2012
e2d::ActionSequence * e2d::Action::Sequence(const InitList<ActionBase*>& vActions)
e2d::ActionSequence * e2d::Action::Sequence(const std::initializer_list<ActionBase*>& vActions)
{
return new (std::nothrow) ActionSequence(vActions);
}
e2d::Animation * e2d::Action::Animation(double interval, const InitList<Image*>& vFrames)
e2d::Animation * e2d::Action::Animation(double interval, const std::initializer_list<Image*>& vFrames)
{
return new (std::nothrow) e2d::Animation(interval, vFrames);
}

View File

@ -21,17 +21,17 @@ bool e2d::ActionBase::isRunning()
return m_bRunning;
}
bool e2d::ActionBase::_isEnding()
bool e2d::ActionBase::_isDone()
{
return m_bEnding;
}
void e2d::ActionBase::setTarget(Node* pTarget)
void e2d::ActionBase::startWithTarget(Node* target)
{
if (pTarget)
if (target)
{
m_bRunning = true;
m_pTarget = pTarget;
m_pTarget = target;
this->reset();
}
}

View File

@ -1,6 +1,6 @@
#include "..\e2daction.h"
e2d::ActionFunc::ActionFunc(Function func) :
e2d::ActionFunc::ActionFunc(const Function& func) :
m_Callback(func)
{
}

View File

@ -38,7 +38,7 @@ void e2d::ActionLoop::_update()
m_pAction->_update();
if (m_pAction->_isEnding())
if (m_pAction->_isDone())
{
m_nTimes++;

View File

@ -6,7 +6,7 @@ e2d::ActionSequence::ActionSequence()
}
#ifdef HIGHER_THAN_VS2012
e2d::ActionSequence::ActionSequence(const InitList<ActionBase*>& vActions)
e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions)
: m_nActionIndex(0)
{
this->add(vActions);
@ -62,7 +62,7 @@ void e2d::ActionSequence::_update()
auto &action = m_vActions[m_nActionIndex];
action->_update();
if (action->_isEnding())
if (action->_isDone())
{
m_nActionIndex++;
if (m_nActionIndex == m_vActions.size())
@ -104,7 +104,7 @@ void e2d::ActionSequence::add(ActionBase * action)
}
#ifdef HIGHER_THAN_VS2012
void e2d::ActionSequence::add(const InitList<ActionBase*>& vActions)
void e2d::ActionSequence::add(const std::initializer_list<ActionBase*>& vActions)
{
for (const auto &action : vActions)
{

View File

@ -45,11 +45,11 @@ void e2d::ActionTwo::_update()
{
ActionBase::_update();
if (!m_pFirstAction->_isEnding())
if (!m_pFirstAction->_isDone())
{
m_pFirstAction->_update();
if (!m_bAtSameTime && m_pFirstAction->_isEnding())
if (!m_bAtSameTime && m_pFirstAction->_isDone())
{
m_pSecondAction->_init();
}
@ -57,17 +57,17 @@ void e2d::ActionTwo::_update()
if (m_bAtSameTime)
{
if (!m_pSecondAction->_isEnding())
if (!m_pSecondAction->_isDone())
{
m_pSecondAction->_update();
}
}
else if (m_pFirstAction->_isEnding())
else if (m_pFirstAction->_isDone())
{
m_pSecondAction->_update();
}
if (m_pFirstAction->_isEnding() && m_pSecondAction->_isEnding())
if (m_pFirstAction->_isDone() && m_pSecondAction->_isDone())
{
this->stop();
}

View File

@ -14,14 +14,14 @@ e2d::Animation::Animation(double interval)
#ifdef HIGHER_THAN_VS2012
e2d::Animation::Animation(const InitList<Image*>& vImages)
e2d::Animation::Animation(const std::initializer_list<Image*>& vImages)
: m_nFrameIndex(0)
, m_fInterval(1)
{
this->add(vImages);
}
e2d::Animation::Animation(double interval, const InitList<Image*>& vImages)
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages)
: m_nFrameIndex(0)
, m_fInterval(interval)
{
@ -128,7 +128,7 @@ void e2d::Animation::add(Image * frame)
}
#ifdef HIGHER_THAN_VS2012
void e2d::Animation::add(const InitList<Image*>& vImages)
void e2d::Animation::add(const std::initializer_list<Image*>& vImages)
{
for (const auto &image : vImages)
{

View File

@ -10,7 +10,6 @@ e2d::Scene::Scene()
, m_pRoot(new Node())
{
m_pRoot->retain();
m_pRoot->_onEnter();
m_pRoot->_setParentScene(this);
}
@ -53,7 +52,7 @@ void e2d::Scene::add(Node * child, int order /* = 0 */)
}
#ifdef HIGHER_THAN_VS2012
void e2d::Scene::add(const InitList<Node*>& vNodes, int order)
void e2d::Scene::add(const std::initializer_list<Node*>& vNodes, int order)
{
for (const auto &node : vNodes)
{

View File

@ -15,7 +15,7 @@ void e2d::ActionManager::__update()
{
auto action = s_vRunningActions[i];
// 获取动作运行状态
if (action->_isEnding())
if (action->_isDone())
{
// 动作已经结束
action->release();
@ -66,7 +66,7 @@ void e2d::ActionManager::__startAction(ActionBase * pAction, Node * pTargetNode)
if (pAction)
{
pAction->setTarget(pTargetNode);
pAction->startWithTarget(pTargetNode);
pAction->retain();
s_vRunningActions.push_back(pAction);
}

View File

@ -8,7 +8,7 @@ class Listener
{
public:
Listener(
e2d::Function func,
const e2d::Function& func,
const e2d::String& name,
bool paused
)
@ -59,17 +59,17 @@ void e2d::ColliderManager::__update()
for (size_t i = 0; i < s_vListeners.size(); i++)
{
auto pListener = s_vListeners[i];
auto listener = s_vListeners[i];
// 清除已停止的监听器
if (pListener->stopped)
if (listener->stopped)
{
delete pListener;
delete listener;
s_vListeners.erase(s_vListeners.begin() + i);
}
else
{
// 更新监听器
pListener->update();
listener->update();
++i;
}
}
@ -133,7 +133,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
s_pPassiveNode = nullptr;
}
void e2d::ColliderManager::add(Function func, const String& name, bool paused)
void e2d::ColliderManager::add(const Function& func, const String& name, bool paused)
{
auto listener = new Listener(func, name, paused);
s_vListeners.push_back(listener);
@ -141,58 +141,58 @@ void e2d::ColliderManager::add(Function func, const String& name, bool paused)
void e2d::ColliderManager::pause(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->running = false;
listener->running = false;
}
}
}
void e2d::ColliderManager::resume(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->running = true;
listener->running = true;
}
}
}
void e2d::ColliderManager::stop(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->stopped = true;
listener->stopped = true;
}
}
}
void e2d::ColliderManager::pauseAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->running = false;
listener->running = false;
}
}
void e2d::ColliderManager::resumeAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->running = true;
listener->running = true;
}
}
void e2d::ColliderManager::stopAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->stopped = true;
listener->stopped = true;
}
}

View File

@ -6,7 +6,7 @@ class Listener
{
public:
Listener(
e2d::Function func,
const e2d::Function& func,
const e2d::String& name,
bool paused
)
@ -37,7 +37,7 @@ public:
static std::vector<Listener*> s_vListeners;
void e2d::InputManager::add(Function func, const String& name, bool paused)
void e2d::InputManager::add(const Function& func, const String& name, bool paused)
{
auto listener = new Listener(func, name, paused);
s_vListeners.push_back(listener);
@ -45,58 +45,58 @@ void e2d::InputManager::add(Function func, const String& name, bool paused)
void e2d::InputManager::pause(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->running = false;
listener->running = false;
}
}
}
void e2d::InputManager::resume(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->running = true;
listener->running = true;
}
}
}
void e2d::InputManager::stop(const String& name)
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
if (pListener->name == name)
if (listener->name == name)
{
pListener->stopped = true;
listener->stopped = true;
}
}
}
void e2d::InputManager::pauseAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->running = false;
listener->running = false;
}
}
void e2d::InputManager::resumeAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->running = true;
listener->running = true;
}
}
void e2d::InputManager::stopAll()
{
for (auto pListener : s_vListeners)
for (auto listener : s_vListeners)
{
pListener->stopped = true;
listener->stopped = true;
}
}
@ -107,17 +107,17 @@ void e2d::InputManager::__update()
for (size_t i = 0; i < s_vListeners.size(); i++)
{
auto pListener = s_vListeners[i];
auto listener = s_vListeners[i];
// 清除已停止的监听器
if (pListener->stopped)
if (listener->stopped)
{
delete pListener;
delete listener;
s_vListeners.erase(s_vListeners.begin() + i);
}
else
{
// 更新监听器
pListener->update();
listener->update();
++i;
}
}

View File

@ -102,7 +102,7 @@ void e2d::SceneManager::__update()
// 更新场景动画
s_pTransition->_update();
if (s_pTransition->isEnding())
if (s_pTransition->isDone())
{
s_pTransition->release();
s_pTransition = nullptr;

View File

@ -16,7 +16,7 @@ e2d::Button::Button()
{
}
e2d::Button::Button(Node * normal, Function func)
e2d::Button::Button(Node * normal, const Function& func)
: m_Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true)
@ -30,7 +30,7 @@ e2d::Button::Button(Node * normal, Function func)
this->setClickFunc(func);
}
e2d::Button::Button(Node * normal, Node * selected, Function func)
e2d::Button::Button(Node * normal, Node * selected, const Function& func)
: m_Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true)
@ -45,7 +45,7 @@ e2d::Button::Button(Node * normal, Node * selected, Function func)
this->setClickFunc(func);
}
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function func)
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func)
: m_Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true)
@ -61,7 +61,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function f
this->setClickFunc(func);
}
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, Function func)
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func)
: m_Callback(nullptr)
, m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true)
@ -170,7 +170,7 @@ void e2d::Button::setEnable(bool enable)
}
}
void e2d::Button::setClickFunc(Function func)
void e2d::Button::setClickFunc(const Function& func)
{
WARN_IF(m_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");

View File

@ -14,7 +14,7 @@ e2d::ButtonToggle::ButtonToggle()
{
}
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Function func)
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, const Function& func)
: Button()
, m_bState(true)
, m_pNormalOn(nullptr)
@ -31,7 +31,7 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, F
this->setClickFunc(func);
}
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, Function func)
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
: Button()
, m_bState(true)
, m_pNormalOn(nullptr)
@ -50,7 +50,7 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
this->setClickFunc(func);
}
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Function func)
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, const Function& func)
: Button()
, m_bState(true)
, m_pNormalOn(nullptr)
@ -71,7 +71,7 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
this->setClickFunc(func);
}
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, Function func)
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, const Function& func)
: Button()
, m_bState(true)
, m_pNormalOn(nullptr)

View File

@ -6,7 +6,7 @@ e2d::Menu::Menu()
}
#ifdef HIGHER_THAN_VS2012
e2d::Menu::Menu(const InitList<Button*>& vButtons)
e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
: m_bEnable(true)
{
for (auto button : vButtons)

View File

@ -27,7 +27,6 @@ e2d::Node::Node()
, m_MatriInitial(D2D1::Matrix3x2F::Identity())
, m_MatriFinal(D2D1::Matrix3x2F::Identity())
, m_bVisiable(true)
, m_bDisplayedInScene(false)
, m_pCollider(nullptr)
, m_pParent(nullptr)
, m_pParentScene(nullptr)
@ -174,34 +173,6 @@ void e2d::Node::_drawCollider()
}
}
void e2d::Node::_onEnter()
{
if (!this->m_bDisplayedInScene)
{
this->m_bDisplayedInScene = true;
this->onEnter();
for (auto child : m_vChildren)
{
child->_onEnter();
}
}
}
void e2d::Node::_onExit()
{
if (this->m_bDisplayedInScene)
{
this->m_bDisplayedInScene = false;
this->onExit();
for (auto child : m_vChildren)
{
child->_onExit();
}
}
}
void e2d::Node::_updateSelfTransform()
{
// 计算中心点坐标
@ -627,7 +598,7 @@ void e2d::Node::addColliableName(const String& collliderName)
}
#ifdef HIGHER_THAN_VS2012
void e2d::Node::addColliableName(const InitList<String>& vCollliderName)
void e2d::Node::addColliableName(const std::initializer_list<String>& vCollliderName)
{
for (const auto &name : vCollliderName)
{
@ -668,11 +639,6 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
child->_setParentScene(this->m_pParentScene);
}
if (this->m_bDisplayedInScene)
{
child->_onEnter();
}
// 更新子节点透明度
child->_updateOpacity();
// 更新节点转换
@ -683,7 +649,7 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
}
#ifdef HIGHER_THAN_VS2012
void e2d::Node::addChild(const InitList<Node*>& vNodes, int order)
void e2d::Node::addChild(const std::initializer_list<Node*>& vNodes, int order)
{
for (const auto &node : vNodes)
{
@ -774,10 +740,6 @@ bool e2d::Node::removeChild(Node * child)
{
child->_setParentScene(nullptr);
}
if (child->m_bDisplayedInScene)
{
child->_onExit();
}
child->release();
return true;
@ -811,10 +773,6 @@ void e2d::Node::removeChildren(const String& childName)
{
child->_setParentScene(nullptr);
}
if (child->m_bDisplayedInScene)
{
child->_onExit();
}
child->release();
}
}
@ -825,10 +783,6 @@ void e2d::Node::clearAllChildren()
// 所有节点的引用计数减一
for (auto child : m_vChildren)
{
if (child->m_bDisplayedInScene)
{
child->_onExit();
}
child->release();
}
// 清空储存节点的容器

View File

@ -5,7 +5,7 @@ class TimerInfo
{
public:
TimerInfo(
e2d::Function func,
const e2d::Function& func,
const e2d::String& name,
double delay,
int updateTimes,
@ -65,18 +65,18 @@ public:
static std::vector<TimerInfo*> s_vTimers;
void e2d::Timer::start(Function func, double delay, int updateTimes, bool paused, const String& name)
void e2d::Timer::start(const Function& func, double delay, int updateTimes, bool paused, const String& name)
{
auto timer = new TimerInfo(func, name, delay, updateTimes, paused);
s_vTimers.push_back(timer);
}
void e2d::Timer::start(Function func, const String& name)
void e2d::Timer::start(const Function& func, const String& name)
{
Timer::start(func, 0, -1, false, name);
}
void e2d::Timer::startOnce(Function func, double timeOut)
void e2d::Timer::startOnce(const Function& func, double timeOut)
{
auto timer = new TimerInfo(func, L"", timeOut, 1, false);
s_vTimers.push_back(timer);

View File

@ -22,7 +22,7 @@ e2d::TransitionBase::~TransitionBase()
SafeReleaseInterface(&m_pNextLayer);
}
bool e2d::TransitionBase::isEnding()
bool e2d::TransitionBase::isDone()
{
return m_bEnd;
}

View File

@ -120,19 +120,19 @@ public:
// 创建执行函数对象的动作
static e2d::ActionFunc* Func(
Function func /* 函数对象 */
const Function& func /* 函数对象 */
);
#ifdef HIGHER_THAN_VS2012
// 创建顺序动作
static e2d::ActionSequence* Sequence(
const InitList<ActionBase*>& vActions /* 动作数组 */
const std::initializer_list<ActionBase*>& vActions /* 动作列表 */
);
// 创建特定帧间隔的帧动画
static e2d::Animation* Animation(
double interval, /* 帧间隔(秒) */
const InitList<Image*>& vFrames /* 关键帧数组 */
double interval, /* 帧间隔(秒) */
const std::initializer_list<Image*>& vFrames /* 关键帧列表 */
);
#else
// 创建顺序动作
@ -171,8 +171,8 @@ public:
virtual bool isRunning();
// 开始动作
virtual void setTarget(
Node* pTarget /* 执行该动作的目标 */
virtual void startWithTarget(
Node* target /* 执行该动作的目标 */
);
// 继续动作
@ -215,7 +215,7 @@ protected:
virtual void _update();
// 获取动作结束状态
virtual bool _isEnding();
virtual bool _isDone();
// 重置动画时间
virtual void _resetTime();
@ -231,6 +231,7 @@ protected:
};
// 持续动作
class ActionGradual :
public ActionBase
{
@ -253,6 +254,7 @@ protected:
};
// 相对位移动画
class ActionMoveBy :
public ActionGradual
{
@ -282,6 +284,7 @@ protected:
};
// 位移动画
class ActionMoveTo :
public ActionMoveBy
{
@ -304,6 +307,7 @@ protected:
};
// 相对缩放动画
class ActionScaleBy :
public ActionGradual
{
@ -342,6 +346,7 @@ protected:
};
// 缩放动画
class ActionScaleTo :
public ActionScaleBy
{
@ -372,6 +377,7 @@ protected:
};
// 透明度相对渐变动画
class ActionOpacityBy :
public ActionGradual
{
@ -401,6 +407,7 @@ protected:
};
// 透明度渐变动画
class ActionOpacityTo :
public ActionOpacityBy
{
@ -423,6 +430,7 @@ protected:
};
// 淡入动画
class ActionFadeIn :
public ActionOpacityTo
{
@ -434,6 +442,7 @@ public:
};
// 淡出动画
class ActionFadeOut :
public ActionOpacityTo
{
@ -445,6 +454,7 @@ public:
};
// 相对旋转动作
class ActionRotateBy :
public ActionGradual
{
@ -474,6 +484,7 @@ protected:
};
// 旋转动作
class ActionRotateTo :
public ActionRotateBy
{
@ -496,6 +507,7 @@ protected:
};
// 组合动作
class ActionTwo :
public ActionBase
{
@ -540,6 +552,7 @@ protected:
};
// 顺序动作
class ActionSequence :
public ActionBase
{
@ -550,7 +563,7 @@ public:
#ifdef HIGHER_THAN_VS2012
// 创建顺序动作
ActionSequence(
const InitList<ActionBase*>& vActions /* 动作数组 */
const std::initializer_list<ActionBase*>& vActions /* 动作列表 */
);
#else
// 创建顺序动作
@ -571,7 +584,7 @@ public:
#ifdef HIGHER_THAN_VS2012
// 在结尾添加多个动作
void add(
const InitList<ActionBase*>& vActions /* 动作数组 */
const std::initializer_list<ActionBase*>& vActions /* 动作列表 */
);
#else
// 在结尾添加多个动作
@ -612,6 +625,7 @@ protected:
};
// 延时动作
class ActionDelay :
public ActionBase
{
@ -636,6 +650,7 @@ protected:
};
// 循环动作
class ActionLoop :
public ActionBase
{
@ -674,6 +689,7 @@ protected:
};
// 帧动画
class Animation :
public ActionBase
{
@ -689,13 +705,13 @@ public:
#ifdef HIGHER_THAN_VS2012
// 创建帧动画
Animation(
const InitList<Image*>& vImages /* 关键帧数组 */
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
);
// 创建特定帧间隔的帧动画
Animation(
double interval, /* 帧间隔(秒) */
const InitList<Image*>& vImages /* 关键帧数组 */
double interval, /* 帧间隔(秒) */
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
);
#else
// 创建帧动画
@ -724,7 +740,7 @@ public:
#ifdef HIGHER_THAN_VS2012
// 添加多个关键帧
void add(
const InitList<Image*>& vImages /* 关键帧数组 */
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
);
#else
// 添加多个关键帧
@ -766,13 +782,14 @@ protected:
};
// 回调动作
class ActionFunc :
public ActionBase
{
public:
// 创建执行函数对象的动作
ActionFunc(
Function func /* 函数对象 */
const Function& func /* 函数对象 */
);
// 获取该动作的拷贝对象

View File

@ -11,15 +11,6 @@ namespace e2d
{
#ifdef HIGHER_THAN_VS2012
// 初始化列表
template <typename T>
using InitList = std::initializer_list<T>;
#endif
struct Size;
// 表示坐标的结构体
@ -561,12 +552,7 @@ public:
);
template<typename Func>
Function(
Func func
)
: m_func(func)
{
}
Function(Func func) : m_func(func) {}
template<typename Func, typename Object>
Function(
@ -771,8 +757,8 @@ public:
#ifdef HIGHER_THAN_VS2012
// 添加多个节点到场景
virtual void add(
const InitList<Node*>& vNodes, /* 节点数组 */
int order = 0 /* 渲染顺序 */
const std::initializer_list<Node*>& vNodes, /* 节点列表 */
int order = 0 /* 渲染顺序 */
);
#endif

View File

@ -182,7 +182,7 @@ class InputManager
public:
// 添加输入监听
static void add(
Function func, /* 监听到用户输入时的执行函数 */
const Function& func, /* 监听到用户输入时的执行函数 */
const String& name = L"", /* 监听器名称 */
bool paused = false /* 是否暂停 */
);
@ -235,7 +235,7 @@ public:
// 添加碰撞监听
static void add(
Function func, /* 监听到碰撞时的执行函数 */
const Function& func, /* 监听到碰撞时的执行函数 */
const String& name = L"", /* 监听器名称 */
bool paused = false /* 是否暂停 */
);

View File

@ -23,12 +23,6 @@ public:
virtual ~Node();
// 进入场景时执行
virtual void onEnter() {}
// 离开场景时执行
virtual void onExit() {}
// 更新节点
virtual void onUpdate() {}
@ -347,7 +341,7 @@ public:
#ifdef HIGHER_THAN_VS2012
// 添加多个可碰撞节点的名称
virtual void addColliableName(
const InitList<String>& vCollliderName /* 名称数组 */
const std::initializer_list<String>& vCollliderName /* 名称列表 */
);
#endif
@ -365,8 +359,8 @@ public:
#ifdef HIGHER_THAN_VS2012
// 添加多个子节点
virtual void addChild(
const InitList<Node*>& vNodes, /* 节点数组 */
int order = 0 /* 渲染顺序 */
const std::initializer_list<Node*>& vNodes, /* 节点列表 */
int order = 0 /* 渲染顺序 */
);
#endif
@ -433,12 +427,6 @@ protected:
// 渲染图形
void _drawCollider();
// 节点被添加到场景时的执行程序
void _onEnter();
// 节点从场景中消失时的执行程序
void _onExit();
// 设置节点所在场景
void _setParentScene(
Scene * scene
@ -472,7 +460,6 @@ protected:
int m_nOrder;
bool m_bVisiable;
bool m_bAutoUpdate;
bool m_bDisplayedInScene;
bool m_bSortChildrenNeeded;
bool m_bTransformNeeded;
bool m_bPositionFixed;
@ -764,32 +751,32 @@ public:
// 创建按钮
Button(
Node * normal, /* 普通状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * normal, /* 普通状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建按钮
Button(
Node * normal, /* 普通状态 */
Node * selected, /* 鼠标按下状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * normal, /* 普通状态 */
Node * selected, /* 鼠标按下状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建按钮
Button(
Node * normal, /* 普通状态 */
Node * mouseover, /* 鼠标移入状态 */
Node * selected, /* 鼠标按下状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * normal, /* 普通状态 */
Node * mouseover, /* 鼠标移入状态 */
Node * selected, /* 鼠标按下状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建按钮
Button(
Node * normal, /* 普通状态 */
Node * mouseover, /* 鼠标移入状态 */
Node * selected, /* 鼠标移入状态 */
Node * disabled, /* 按钮禁用状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * normal, /* 普通状态 */
Node * mouseover, /* 鼠标移入状态 */
Node * selected, /* 鼠标移入状态 */
Node * disabled, /* 按钮禁用状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 获取按钮状态是启用还是禁用
@ -822,7 +809,7 @@ public:
// 设置按钮点击后的执行函数
void setClickFunc(
Function func
const Function& func
);
// 更新按钮状态
@ -862,42 +849,42 @@ public:
// 创建开关按钮
ButtonToggle(
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建开关按钮
ButtonToggle(
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建开关按钮
ButtonToggle(
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 创建开关按钮
ButtonToggle(
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
Node * onDisabled, /* 按钮打开时,禁用状态 */
Node * offDisabled, /* 按钮关闭时,禁用状态 */
Function func = nullptr /* 按钮点击后的执行函数 */
Node * onNormal, /* 按钮打开时,普通状态 */
Node * offNormal, /* 按钮关闭时,普通状态 */
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
Node * onDisabled, /* 按钮打开时,禁用状态 */
Node * offDisabled, /* 按钮关闭时,禁用状态 */
const Function& func = nullptr /* 按钮点击后的执行函数 */
);
// 获取开关状态(打开或关闭)
@ -978,7 +965,7 @@ public:
#ifdef HIGHER_THAN_VS2012
// 创建菜单
Menu(
const InitList<Button*>& vButtons /* 按钮数组 */
const std::initializer_list<Button*>& vButtons /* 按钮列表 */
);
#else
// 创建菜单

View File

@ -162,16 +162,16 @@ class Timer
friend Game;
public:
// 启动定时器
// 启动定时器(每帧执行一次)
static void start(
Function func, /* 执行函数 */
const String& name /* 定时器名称 */
const Function& func, /* 执行函数 */
const String& name = L"" /* 定时器名称 */
);
// 启动定时器
static void start(
Function func, /* 执行函数 */
double delay = 0, /* 时间间隔(秒) */
const Function& func, /* 执行函数 */
double delay, /* 时间间隔(秒) */
int times = -1, /* 执行次数(设 -1 为永久执行) */
bool paused = false, /* 是否暂停 */
const String& name = L"" /* 定时器名称 */
@ -179,7 +179,7 @@ public:
// 启动仅执行一次的定时器
static void startOnce(
Function func, /* 执行的函数 */
const Function& func, /* 执行的函数 */
double timeOut /* 等待的时长(秒) */
);

View File

@ -51,7 +51,7 @@ public:
virtual ~TransitionBase();
// 场景切换动画是否结束
bool isEnding();
bool isDone();
// 销毁对象
virtual void destroy() override;