Log all children types of a CCNode in cocos2dx - Plunge Interactive

Log all children types of a CCNode in cocos2dx

In cocos2dx based games, the node hierarchy can sometimes become complex. Sometimes it can even be hard to debug several situations because of this hierarchy. In order to avoid this kind of problems, we have written a small function that prints all the hierarchy of a node and subnodes.

This is the code:

    void printAllChildrenTypes(cocos2d::CCNode* node, int level)
    {
        std::string spaces(level, ' ');

        CCLOG("%s %02d : %s", spaces.c_str(), level, typeid(*node).name());

        ++level;

        cocos2d::CCObject* obj = nullptr;
        CCARRAY_FOREACH(node->getChildren(), obj)
        {
            printAllChildrenTypes(static_cast(obj), level);
        }
    }

And this would be an example of the result in the log console:

Cocos2d: 00 : 21DispatchingScrollView
Cocos2d: 01 : N7cocos2d7CCLayerE
Cocos2d: 02 : N7cocos2d7CCLayerE
Cocos2d: 03 : N7cocos2d8CCSpriteE
Cocos2d: 03 : N7cocos2d9extension15CCControlButtonE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d10CCLabelTTFE
Cocos2d: 03 : N7cocos2d10CCLabelTTFE
Cocos2d: 03 : 21ExtendedControlButton
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d10CCLabelTTFE
Cocos2d: 03 : N7cocos2d8CCSpriteE
Cocos2d: 03 : 21ExtendedControlButton
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d9extension14CCScale9SpriteE
Cocos2d: 05 : N7cocos2d17CCSpriteBatchNodeE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 06 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d10CCLabelTTFE
Cocos2d: 03 : N7cocos2d8CCSpriteE
Cocos2d: 04 : N7cocos2d10CCLabelTTFE
Cocos2d: 04 : N7cocos2d10CCLabelTTFE
Cocos2d: 03 : N7cocos2d8CCSpriteE

This site uses cookies to store information on your computer. Some cookies on this site are essential, and the site won't work as expected without them. Read more about them

ACCEPT