diff --git a/core/Node/Button.cpp b/core/Node/Button.cpp index 0b0631a2..b06f0eb1 100644 --- a/core/Node/Button.cpp +++ b/core/Node/Button.cpp @@ -202,7 +202,7 @@ void e2d::Button::setClickFunc(const Function& func) _func = func; } -void e2d::Button::onFixedUpdate() +void e2d::Button::_fixedUpdate() { if (SceneManager::isTransitioning()) return; diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 28ed88da..55987386 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -92,14 +92,11 @@ void e2d::Node::_update() } } - if (_autoUpdate) + if (_autoUpdate && !Game::isPaused()) { - if (!Game::isPaused()) - { - this->onUpdate(); - } - this->onFixedUpdate(); + this->onUpdate(); } + this->_fixedUpdate(); // 访问剩余节点 for (; i < size; ++i) @@ -107,14 +104,11 @@ void e2d::Node::_update() } else { - if (_autoUpdate) + if (_autoUpdate && !Game::isPaused()) { - if (!Game::isPaused()) - { - this->onUpdate(); - } - this->onFixedUpdate(); + this->onUpdate(); } + this->_fixedUpdate(); } } @@ -236,6 +230,10 @@ void e2d::Node::_updateOpacity() } } +void e2d::Node::_fixedUpdate() +{ +} + bool e2d::Node::isVisiable() const { return _visiable; diff --git a/core/e2dnode.h b/core/e2dnode.h index 5ca61345..16993c3a 100644 --- a/core/e2dnode.h +++ b/core/e2dnode.h @@ -48,9 +48,6 @@ public: // 更新节点 virtual void onUpdate() {} - // 固定地更新(游戏暂停时仍然运行) - virtual void onFixedUpdate() {} - // 渲染节点 virtual void onRender() {} @@ -459,6 +456,9 @@ protected: // 更新节点透明度 void _updateOpacity(); + // 固定更新 + virtual void _fixedUpdate(); + protected: String _name; unsigned _hashName; @@ -963,9 +963,6 @@ public: const Function& func ); - // 更新按钮状态 - virtual void onFixedUpdate() override; - protected: // 按钮状态枚举 enum class ButtonState { NORMAL, MOUSEOVER, SELECTED }; @@ -979,6 +976,9 @@ protected: // 执行按钮函数对象 virtual void _runCallback(); + // 更新按钮状态 + virtual void _fixedUpdate() override; + protected: Node * _normal; Node * _mouseover;