Example #1
0
void CCNode::removeAllChildrenWithCleanup(bool cleanup)
{
	// not using detachChild improves speed here
	if ( m_pChildren && m_pChildren->count() > 0 )
	{
		CCNode * pNode;
		CCMutableArray<CCNode*>::CCMutableArrayIterator it;
		for ( it = m_pChildren->begin(); it!= m_pChildren->end(); it++ )
		{
			pNode = *it;
			if (pNode)
			{
				// IMPORTANT:
				//  -1st do onExit
				//  -2nd cleanup
				if(m_bIsRunning)
				{
					pNode->onExit();
				}

				if (cleanup)
				{
					pNode->cleanup();
				}
				// set parent nil at the end
				pNode->setParent(NULL);
			}
		}
		
		m_pChildren->removeAllObjects();
	}
	
}
Example #2
0
void CCNode::removeAllChildrenWithCleanup(bool cleanup)
{
    // not using detachChild improves speed here
	for( unsigned int i=0, s=m_Children.size(); i<s; ++i )
    {
		CCNode* pNode = (CCNode*) m_Children[i];
        if (pNode)
        {
            if (cleanup)
            {
                pNode->cleanup();
            }
			delete pNode;
        }
        
        m_Children.clear();
    }
}