悉野小楼

导航

列出cocos2dx运行场景所有节点信息

#include <typeinfo.h>

static int showAllChildNodeInfo(Node *rootNode, int layer)
{
    int count = 1;
    Size size = rootNode->getContentSize();
    CCLOG("%s layer[%d], visible[%s], name[%s], tag[%i], posX[%f], posY[%f], width[%d], height[%d], zOrder[%d]", 
        typeid(*rootNode).name(), layer, rootNode->isVisible() ? "true" : "false", rootNode->getName().c_str(),
        rootNode->getTag(), rootNode->getPositionX(), rootNode->getPositionY(), size.width, size.height, rootNode->getZOrder());
    for(auto child : rootNode->getChildren())
    {
        count += showAllChildNodeInfo(child, layer + 1);
    }
    return count;
}
//调用
int totalCount = showAllChildNodeInfo(Director::sharedDirector()->getRunningScene(), 0);
CCLOG("total node count:%d", totalCount);

输出截取部分如下:


class SceneWorld layer[0], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1083441152], z-order[0]
class cocos2d::Camera layer[1], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[0], z-order[0]
class cocos2d::Node layer[1], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[0], z-order[0]
class MyMapNode layer[2], visible[true], name[], tag[-1], posX[-7730.000000], posY[-4740.000000], width[0], height[1087357440], z-order[0]
class MyTileNode layer[3], visible[false], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1083179008], z-order[0]
class MyTileNode layer[3], visible[false], name[], tag[-1], posX[3072.000000], posY[0.000000], width[0], height[1083179008], z-order[0]
class MYNormalButton layer[4], visible[true], name[ChatCopyBtn], tag[-1], posX[473.000000], posY[81.000000], width[0], height[1078689792], z-order[0]
class MYEditBox layer[4], visible[true], name[LuaEditUI], tag[-1], posX[297.000000], posY[23.000000], width[0], height[1081589760], z-order[0]
class cocos2d::Label layer[5], visible[false], name[], tag[-1], posX[5.000000], posY[35.000000], width[0], height[0], z-order[0]
class cocos2d::Label layer[5], visible[true], name[], tag[-1], posX[5.000000], posY[35.000000], width[0], height[1080262656], z-order[0]
class MYEditBox layer[4], visible[false], name[LuaEditUI], tag[-1], posX[390.000000], posY[23.000000], width[0], height[1080705024], z-order[0]
class cocos2d::Label layer[5], visible[false], name[], tag[-1], posX[5.000000], posY[35.000000], width[0], height[0], z-order[0]
class cocos2d::Label layer[5], visible[false], name[], tag[-1], posX[5.000000], posY[35.000000], width[0], height[1080262656], z-order[0]
class MYNormalButton layer[4], visible[true], name[SendBtn], tag[-1], posX[550.000000], posY[22.000000], width[0], height[1079427072], z-order[0]
class TouchText layer[4], visible[false], name[LinePlayerName], tag[-1], posX[97.000000], posY[9.000000], width[0], height[1080475648], z-order[0]
class MYLabel layer[5], visible[true], name[], tag[10], posX[0.000000], posY[0.000000], width[0], height[1080475648], z-order[0]
class cocos2d::Label layer[6], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1080475648], z-order[0]
class cocos2d::DrawNode layer[6], visible[true], name[], tag[10], posX[0.000000], posY[-2.000000], width[0], height[0], z-order[0]
class MYNormalCheckBox layer[4], visible[true], name[OpenChannelBtn], tag[-1], posX[50.000000], posY[23.000000], width[0], height[1079492608], z-order[0]
class MYMenu layer[3], visible[false], name[MenuHandle], tag[-1], posX[18.000000], posY[63.000000], width[0], height[1079492608], z-order[0]
class MYLuaScale9Sprite layer[4], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1079492608], z-order[0]
class MYNormalButton layer[5], visible[true], name[], tag[1], posX[47.000000], posY[242.000000], width[0], height[1079492608], z-order[0]
class CTouchFinger layer[1], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1083441152], z-order[0]
class MYAnimNode layer[2], visible[false], name[], tag[-1], posX[-1000.000000], posY[-1000.000000], width[0], height[1080033280], z-order[0]
class MYUISprite layer[2], visible[false], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[0], z-order[0]
class DownloadProgressUI layer[1], visible[false], name[], tag[99999], posX[640.000000], posY[250.000000], width[0], height[0], z-order[0]
class MYUISprite layer[2], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1081139200], z-order[0]
class MYNormalProgressTimer layer[2], visible[true], name[], tag[-1], posX[19.000000], posY[1.000000], width[0], height[1080573952], z-order[0]
class cocos2d::Label layer[2], visible[true], name[], tag[-1], posX[0.000000], posY[-20.000000], width[0], height[1078034432], z-order[0]
class RideIngProgressUI layer[1], visible[false], name[], tag[99999], posX[640.000000], posY[250.000000], width[0], height[0], z-order[0]
class MYUISprite layer[2], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1081139200], z-order[0]
class MYNormalProgressTimer layer[2], visible[true], name[], tag[-1], posX[19.000000], posY[1.000000], width[0], height[1080573952], z-order[0]
class UseItemProgressUI layer[1], visible[false], name[], tag[99999], posX[640.000000], posY[300.000000], width[0], height[0], z-order[0]
class MYUISprite layer[2], visible[true], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1081139200], z-order[0]
class MYNormalProgressTimer layer[2], visible[true], name[], tag[-1], posX[19.000000], posY[1.000000], width[0], height[1080573952], z-order[0]
class cocos2d::Label layer[2], visible[true], name[], tag[-1], posX[0.000000], posY[-20.000000], width[0], height[1078034432], z-order[0]
class NodeHelper layer[1], visible[false], name[], tag[-1], posX[0.000000], posY[0.000000], width[0], height[1083441152], z-order[0]
class cocos2d::Label layer[2], visible[true], name[], tag[-1], posX[10.000000], posY[600.000000], width[0], height[1079410688], z-order[0]

total node count:2462

posted on 2021-10-22 16:51  悉野  阅读(82)  评论(0编辑  收藏  举报