diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index d2059079..d5255c55 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -1125,6 +1125,11 @@ public: GEODE_DLL geode::EventListenerProtocol* getEventListener(std::string const& id); GEODE_DLL size_t getEventListenerCount(); + /** + * Get nth child that is a given type. Checks bounds. + * @returns Child at index cast to the given type, + * or nullptr if index exceeds bounds + */ template T* getChildByType(int index) { size_t indexCounter = 0; diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp index 0c16818b..5d517a6d 100644 --- a/loader/include/Geode/utils/cocos.hpp +++ b/loader/include/Geode/utils/cocos.hpp @@ -620,7 +620,9 @@ namespace geode::cocos { * @returns Child at index cast to the given type, * or nullptr if index exceeds bounds */ + template + [[deprecated("Use CCNode::getChildByType instead")]] static Type* getChildOfType(cocos2d::CCNode* node, int index) { return node->getChildByType(index); }