2014-03-24 15:25:44 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2009 Valentin Milea
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
https://axys1.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "2d/CCProtectedNode.h"
|
2014-03-24 15:25:44 +08:00
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCDirector.h"
|
2014-05-02 07:42:35 +08:00
|
|
|
#include "2d/CCScene.h"
|
2014-03-24 15:25:44 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2014-03-24 15:25:44 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ProtectedNode::ProtectedNode() : _reorderProtectedChildDirty(false) {}
|
2014-03-24 15:25:44 +08:00
|
|
|
|
|
|
|
ProtectedNode::~ProtectedNode()
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AXLOGINFO("deallocing ProtectedNode: %p - tag: %i", this, _tag);
|
2015-12-17 21:55:47 +08:00
|
|
|
removeAllProtectedChildren();
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ProtectedNode* ProtectedNode::create()
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ProtectedNode* ret = new ProtectedNode();
|
2021-12-08 00:11:53 +08:00
|
|
|
if (ret->init())
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(ret);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
return ret;
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::cleanup()
|
|
|
|
{
|
|
|
|
Node::cleanup();
|
|
|
|
// timers
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
child->cleanup();
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void ProtectedNode::addProtectedChild(ax::Node* child)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
addProtectedChild(child, child->getLocalZOrder(), child->getTag());
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void ProtectedNode::addProtectedChild(ax::Node* child, int localZOrder)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
addProtectedChild(child, localZOrder, child->getTag());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "add" logic MUST only be on this method
|
|
|
|
* If a class want's to extend the 'addChild' behavior it only needs
|
|
|
|
* to override this method
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void ProtectedNode::addProtectedChild(Node* child, int zOrder, int tag)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(child != nullptr, "Argument must be non-nil");
|
|
|
|
AXASSERT(child->getParent() == nullptr, "child already added. It can't be added again");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (_protectedChildren.empty())
|
|
|
|
{
|
|
|
|
_protectedChildren.reserve(4);
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
this->insertProtectedChild(child, zOrder);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-04-15 13:40:44 +08:00
|
|
|
child->setTag(tag);
|
2017-01-04 11:06:44 +08:00
|
|
|
child->setGlobalZOrder(_globalZOrder);
|
2014-04-15 13:40:44 +08:00
|
|
|
child->setParent(this);
|
2016-07-31 22:44:24 +08:00
|
|
|
child->updateOrderOfArrival();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
if (_running)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
child->onEnter();
|
|
|
|
// prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_isTransitionFinished)
|
|
|
|
{
|
2014-03-24 15:25:44 +08:00
|
|
|
child->onEnterTransitionDidFinish();
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (_cascadeColorEnabled)
|
|
|
|
{
|
|
|
|
updateCascadeColor();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (_cascadeOpacityEnabled)
|
|
|
|
{
|
|
|
|
updateCascadeOpacity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Node* ProtectedNode::getProtectedChildByTag(int tag)
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(tag != Node::INVALID_TAG, "Invalid tag");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (child && child->getTag() == tag)
|
2014-03-24 15:25:44 +08:00
|
|
|
return child;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "remove" logic MUST only be on this method
|
|
|
|
* If a class want's to extend the 'removeChild' behavior it only needs
|
|
|
|
* to override this method
|
|
|
|
*/
|
2022-08-08 18:02:17 +08:00
|
|
|
void ProtectedNode::removeProtectedChild(ax::Node* child, bool cleanup)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
// explicit nil handling
|
|
|
|
if (_protectedChildren.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
ssize_t index = _protectedChildren.getIndex(child);
|
2022-07-15 19:17:01 +08:00
|
|
|
if (index != AX_INVALID_INDEX)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
// IMPORTANT:
|
|
|
|
// -1st do onExit
|
|
|
|
// -2nd cleanup
|
|
|
|
if (_running)
|
|
|
|
{
|
|
|
|
child->onExitTransitionDidStart();
|
|
|
|
child->onExit();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
// If you don't do cleanup, the child's actions will not get removed and the
|
|
|
|
// its scheduledSelectors_ dict will not get released!
|
|
|
|
if (cleanup)
|
|
|
|
{
|
|
|
|
child->cleanup();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
// set parent nil at the end
|
|
|
|
child->setParent(nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2016-02-16 13:43:11 +08:00
|
|
|
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
|
|
|
if (sEngine)
|
|
|
|
{
|
|
|
|
sEngine->releaseScriptObject(this, child);
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2014-03-24 15:25:44 +08:00
|
|
|
_protectedChildren.erase(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::removeAllProtectedChildren()
|
|
|
|
{
|
|
|
|
removeAllProtectedChildrenWithCleanup(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::removeAllProtectedChildrenWithCleanup(bool cleanup)
|
|
|
|
{
|
|
|
|
// not using detachChild improves speed here
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
// IMPORTANT:
|
|
|
|
// -1st do onExit
|
|
|
|
// -2nd cleanup
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_running)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
child->onExitTransitionDidStart();
|
|
|
|
child->onExit();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (cleanup)
|
|
|
|
{
|
|
|
|
child->cleanup();
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2016-02-16 13:43:11 +08:00
|
|
|
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
|
|
|
if (sEngine)
|
|
|
|
{
|
|
|
|
sEngine->releaseScriptObject(this, child);
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2014-03-24 15:25:44 +08:00
|
|
|
// set parent nil at the end
|
|
|
|
child->setParent(nullptr);
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
_protectedChildren.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::removeProtectedChildByTag(int tag, bool cleanup)
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(tag != Node::INVALID_TAG, "Invalid tag");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
Node* child = this->getProtectedChildByTag(tag);
|
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (child == nullptr)
|
|
|
|
{
|
2022-09-01 19:51:19 +08:00
|
|
|
AXLOG("axys: removeChildByTag(tag = %d): child not found!", tag);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->removeProtectedChild(child, cleanup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper used by reorderChild & add
|
2022-08-08 18:02:17 +08:00
|
|
|
void ProtectedNode::insertProtectedChild(ax::Node* child, int z)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2016-02-16 13:43:11 +08:00
|
|
|
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
|
|
|
if (sEngine)
|
|
|
|
{
|
|
|
|
sEngine->retainScriptObject(this, child);
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
2014-03-24 15:25:44 +08:00
|
|
|
_reorderProtectedChildDirty = true;
|
|
|
|
_protectedChildren.pushBack(child);
|
2014-09-03 17:26:50 +08:00
|
|
|
child->setLocalZOrder(z);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::sortAllProtectedChildren()
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_reorderProtectedChildDirty)
|
|
|
|
{
|
2016-07-31 22:44:24 +08:00
|
|
|
sortNodes(_protectedChildren);
|
2014-03-24 15:25:44 +08:00
|
|
|
_reorderProtectedChildDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void ProtectedNode::reorderProtectedChild(ax::Node* child, int localZOrder)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(child != nullptr, "Child must be non-nil");
|
2014-03-24 15:25:44 +08:00
|
|
|
_reorderProtectedChildDirty = true;
|
2016-07-31 22:44:24 +08:00
|
|
|
child->updateOrderOfArrival();
|
2014-09-03 17:26:50 +08:00
|
|
|
child->setLocalZOrder(localZOrder);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void ProtectedNode::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
// quick return if not visible. children won't be drawn.
|
2015-06-18 10:32:30 +08:00
|
|
|
if (!_visible)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
// IMPORTANT:
|
2014-05-15 01:07:09 +08:00
|
|
|
// To ease the migration to v3.0, we still support the Mat4 stack,
|
2014-03-24 15:25:44 +08:00
|
|
|
// but it is deprecated and your code should not rely on it
|
2021-02-05 23:09:14 +08:00
|
|
|
_director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
|
|
_director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int i = 0; // used by _children
|
|
|
|
int j = 0; // used by _protectedChildren
|
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
sortAllChildren();
|
|
|
|
sortAllProtectedChildren();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
//
|
|
|
|
// draw children and protectedChildren zOrder < 0
|
|
|
|
//
|
2021-12-25 10:04:45 +08:00
|
|
|
for (auto size = _children.size(); i < size; ++i)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
auto node = _children.at(i);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
if (node && node->getLocalZOrder() < 0)
|
2014-05-31 07:42:05 +08:00
|
|
|
node->visit(renderer, _modelViewTransform, flags);
|
2014-03-24 15:25:44 +08:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2016-10-27 15:10:24 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (auto size = _protectedChildren.size(); j < size; ++j)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
|
|
|
auto node = _protectedChildren.at(j);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
if (node && node->getLocalZOrder() < 0)
|
2014-05-31 07:42:05 +08:00
|
|
|
node->visit(renderer, _modelViewTransform, flags);
|
2014-03-24 15:25:44 +08:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
//
|
|
|
|
// draw self
|
|
|
|
//
|
2014-08-14 10:26:37 +08:00
|
|
|
if (isVisitableByVisitingCamera())
|
2014-08-13 12:06:51 +08:00
|
|
|
this->draw(renderer, _modelViewTransform, flags);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
//
|
|
|
|
// draw children and protectedChildren zOrder >= 0
|
|
|
|
//
|
2021-12-25 10:04:45 +08:00
|
|
|
for (auto it = _protectedChildren.cbegin() + j, itCend = _protectedChildren.cend(); it != itCend; ++it)
|
2014-05-31 07:42:05 +08:00
|
|
|
(*it)->visit(renderer, _modelViewTransform, flags);
|
2016-10-27 15:10:24 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (auto it = _children.cbegin() + i, itCend = _children.cend(); it != itCend; ++it)
|
2014-05-31 07:42:05 +08:00
|
|
|
(*it)->visit(renderer, _modelViewTransform, flags);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-11 15:44:31 +08:00
|
|
|
// FIX ME: Why need to set _orderOfArrival to 0??
|
|
|
|
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
|
|
|
// setOrderOfArrival(0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2021-02-05 23:09:14 +08:00
|
|
|
_director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::onEnter()
|
|
|
|
{
|
|
|
|
Node::onEnter();
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
child->onEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::onEnterTransitionDidFinish()
|
|
|
|
{
|
|
|
|
Node::onEnterTransitionDidFinish();
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
child->onEnterTransitionDidFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::onExitTransitionDidStart()
|
|
|
|
{
|
|
|
|
Node::onExitTransitionDidStart();
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
child->onExitTransitionDidStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::onExit()
|
|
|
|
{
|
|
|
|
Node::onExit();
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
2014-03-24 15:25:44 +08:00
|
|
|
child->onExit();
|
|
|
|
}
|
|
|
|
|
2019-06-05 17:58:33 +08:00
|
|
|
void ProtectedNode::updateDisplayedOpacity(uint8_t parentOpacity)
|
2014-03-24 15:25:44 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_displayedOpacity = _realOpacity * parentOpacity / 255.0;
|
2014-03-24 15:25:44 +08:00
|
|
|
updateColor();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (_cascadeOpacityEnabled)
|
|
|
|
{
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _children)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-03-24 15:25:44 +08:00
|
|
|
child->updateDisplayedOpacity(_displayedOpacity);
|
|
|
|
}
|
2014-08-06 16:21:00 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-08-11 15:04:00 +08:00
|
|
|
child->updateDisplayedOpacity(_displayedOpacity);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::updateDisplayedColor(const Color3B& parentColor)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_displayedColor.r = _realColor.r * parentColor.r / 255.0;
|
|
|
|
_displayedColor.g = _realColor.g * parentColor.g / 255.0;
|
|
|
|
_displayedColor.b = _realColor.b * parentColor.b / 255.0;
|
2014-03-24 15:25:44 +08:00
|
|
|
updateColor();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-24 15:25:44 +08:00
|
|
|
if (_cascadeColorEnabled)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _children)
|
|
|
|
{
|
2014-03-24 15:25:44 +08:00
|
|
|
child->updateDisplayedColor(_displayedColor);
|
|
|
|
}
|
2014-08-06 16:21:00 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
for (const auto& child : _protectedChildren)
|
|
|
|
{
|
2014-08-11 15:04:00 +08:00
|
|
|
child->updateDisplayedColor(_displayedColor);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProtectedNode::disableCascadeColor()
|
|
|
|
{
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _children)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-03-24 15:25:44 +08:00
|
|
|
child->updateDisplayedColor(Color3B::WHITE);
|
|
|
|
}
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-08-11 15:04:00 +08:00
|
|
|
child->updateDisplayedColor(Color3B::WHITE);
|
2014-03-24 15:25:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-22 11:49:39 +08:00
|
|
|
void ProtectedNode::disableCascadeOpacity()
|
|
|
|
{
|
|
|
|
_displayedOpacity = _realOpacity;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _children)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-08-22 11:49:39 +08:00
|
|
|
child->updateDisplayedOpacity(255);
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2014-08-22 11:49:39 +08:00
|
|
|
child->updateDisplayedOpacity(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-12 09:24:04 +08:00
|
|
|
void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren)
|
|
|
|
{
|
|
|
|
Node::setCameraMask(mask, applyChildren);
|
|
|
|
if (applyChildren)
|
|
|
|
{
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& iter : _protectedChildren)
|
2015-02-12 09:24:04 +08:00
|
|
|
{
|
|
|
|
iter->setCameraMask(mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-04 11:06:44 +08:00
|
|
|
void ProtectedNode::setGlobalZOrder(float globalZOrder)
|
|
|
|
{
|
|
|
|
Node::setGlobalZOrder(globalZOrder);
|
2022-07-21 19:19:08 +08:00
|
|
|
for (auto&& child : _protectedChildren)
|
2017-01-04 11:06:44 +08:00
|
|
|
child->setGlobalZOrder(globalZOrder);
|
|
|
|
}
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|