本文整理汇总了C++中CCNode::getOrderOfArrival方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getOrderOfArrival方法的具体用法?C++ CCNode::getOrderOfArrival怎么用?C++ CCNode::getOrderOfArrival使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::getOrderOfArrival方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sortAllChildren
//override sortAllChildren
void CCSpriteBatchNode::sortAllChildren()
{
if (m_bReorderChildDirty)
{
int i = 0,j = 0,length = m_pChildren->data->num;
CCNode ** x = (CCNode**)m_pChildren->data->arr;
CCNode *tempItem = NULL;
//insertion sort
for(i=1; i<length; i++)
{
tempItem = x[i];
j = i-1;
//continue moving element downwards while zOrder is smaller or when zOrder is the same but orderOfArrival is smaller
while(j>=0 && ( tempItem->getZOrder() < x[j]->getZOrder() || ( tempItem->getZOrder() == x[j]->getZOrder() && tempItem->getOrderOfArrival() < x[j]->getOrderOfArrival() ) ) )
{
x[j+1] = x[j];
j--;
}
x[j+1] = tempItem;
}
//sorted now check all children
if (m_pChildren->count() > 0)
{
//first sort all children recursively based on zOrder
arrayMakeObjectsPerformSelector(m_pChildren, sortAllChildren, CCSprite*);
int index=0;
CCObject* pObj = NULL;
//fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact)
// and at the same time reorder descendants and the quads to the right index
CCARRAY_FOREACH(m_pChildren, pObj)
{
CCSprite* pChild = (CCSprite*)pObj;
updateAtlasIndex(pChild, &index);
}
}
示例2: sortAllChildren
void Widget::sortAllChildren()
{
_reorderWidgetChildDirty = m_bReorderChildDirty;
CCNode::sortAllChildren();
if( _reorderWidgetChildDirty )
{
int i,j,length = _widgetChildren->data->num;
CCNode ** x = (CCNode**)_widgetChildren->data->arr;
CCNode *tempItem;
// insertion sort
for(i=1; i<length; i++)
{
tempItem = x[i];
j = i-1;
//continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
while(j>=0 && ( tempItem->getZOrder() < x[j]->getZOrder() || ( tempItem->getZOrder()== x[j]->getZOrder() && tempItem->getOrderOfArrival() < x[j]->getOrderOfArrival() ) ) )
{
x[j+1] = x[j];
j = j-1;
}
x[j+1] = tempItem;
}
//don't need to check children recursively, that's done in visit of each child
_reorderWidgetChildDirty = false;
}
}