Skip to content

Commit d5296bf

Browse files
committed
deprecate the free function getChild
1 parent ffb8bd2 commit d5296bf

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

loader/include/Geode/utils/cocos.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,18 +642,13 @@ namespace geode::cocos {
642642
/**
643643
* Get child at index. Checks bounds. A negative
644644
* index will get the child starting from the end
645+
* @deprecated Use CCNode::getChildByIndex instead
645646
* @returns Child at index cast to the given type,
646647
* or nullptr if index exceeds bounds
647648
*/
648649
template <class T = cocos2d::CCNode>
649650
static T* getChild(cocos2d::CCNode* x, int i) {
650-
// start from end for negative index
651-
if (i < 0) i = x->getChildrenCount() + i;
652-
// check if backwards index is out of bounds
653-
if (i < 0) return nullptr;
654-
// check if forwards index is out of bounds
655-
if (static_cast<int>(x->getChildrenCount()) <= i) return nullptr;
656-
return static_cast<T*>(x->getChildren()->objectAtIndex(i));
651+
return x->getChildByIndex<T>(i);
657652
}
658653

659654
/**

0 commit comments

Comments
 (0)