add CCNode::removeChildByID

This commit is contained in:
HJfod 2023-03-11 10:19:26 +02:00
parent 72ee7755d2
commit 5f3c6587b3
2 changed files with 12 additions and 0 deletions

View file

@ -699,6 +699,12 @@ public:
* @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
*/
virtual void removeChildByTag(int tag, bool cleanup);
/**
* Removes a child from the container by its ID.
* @param id The ID of the node
* @note Geode addition
*/
void removeChildByID(std::string const& id);
/**
* Removes all children from the container with a cleanup.
*

View file

@ -122,6 +122,12 @@ CCNode* CCNode::getChildByIDRecursive(std::string const& id) {
return nullptr;
}
void CCNode::removeChildByID(std::string const& id) {
if (auto child = this->getChildByID(id)) {
this->removeChild(child);
}
}
void CCNode::setLayout(Layout* layout, bool apply, bool respectAnchor) {
if (respectAnchor && this->isIgnoreAnchorPointForPosition()) {
for (auto child : CCArrayExt<CCNode>(m_pChildren)) {