diff --git a/Easy2D/Object/BatchNode.cpp b/Easy2D/Object/BatchNode.cpp index f810db7e..63716580 100644 --- a/Easy2D/Object/BatchNode.cpp +++ b/Easy2D/Object/BatchNode.cpp @@ -99,6 +99,16 @@ bool BatchNode::del(Node * child) return false; } +int BatchNode::getCount() +{ + return (int)m_vChildren.size(); +} + +std::vector& BatchNode::getChildren() +{ + return m_vChildren; +} + void BatchNode::clearAllChildren() { // 所有节点的引用计数减一 diff --git a/Easy2D/Object/BatchSprite.cpp b/Easy2D/Object/BatchSprite.cpp index c35a04b6..edbb9e84 100644 --- a/Easy2D/Object/BatchSprite.cpp +++ b/Easy2D/Object/BatchSprite.cpp @@ -60,6 +60,16 @@ bool BatchSprite::delSprite(Sprite * sprite) return false; } +int BatchSprite::getCount() +{ + return (int)m_vSprites.size(); +} + +std::vector& BatchSprite::getChildren() +{ + return m_vSprites; +} + void BatchSprite::clearAllSprites() { // 所有节点的引用计数减一 diff --git a/Easy2D/easy2d.h b/Easy2D/easy2d.h index e4761458..7336b713 100644 --- a/Easy2D/easy2d.h +++ b/Easy2D/easy2d.h @@ -561,6 +561,10 @@ public: void add(Node *child, int z_Order = 0); // 删除子节点 bool del(Node * child); + // 获取子节点数量 + int getCount(); + // 获取所有子节点 + std::vector &getChildren(); // 清空所有子节点 void clearAllChildren(); @@ -840,6 +844,10 @@ public: void addSprite(Sprite * sprite, int z_Order = 0); // 删除精灵 bool delSprite(Sprite * child); + // 获取精灵数量 + int getCount(); + // 获取所有精灵 + std::vector &getChildren(); // 删除所有精灵 void clearAllSprites(); // 判断是否有精灵产生碰撞