本文整理汇总了C++中CCNode::getZOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getZOrder方法的具体用法?C++ CCNode::getZOrder怎么用?C++ CCNode::getZOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::getZOrder方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: ccTouchesEnded
void LCWordCloudLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
if (!m_bIsMoved) {
// tap action : select something
CCNode *selectedNode = NULL;
for (int i=0; i<m_pNodeArray->count(); i++) {
CCNode *pNode = (CCNode *)m_pNodeArray->objectAtIndex(i);
if (LCUtil::isTouchInside(pNode, pTouches)) {
if (selectedNode) {
if (selectedNode->getZOrder() < pNode->getZOrder()) {
selectedNode = pNode;
}
} else {
selectedNode = pNode;
}
}
}
if (selectedNode) {
if (m_pLCWordCloudLayerDelegate) {
m_pLCWordCloudLayerDelegate->wordCloudDidSelectedWord(this, selectedNode);
} else {
CCLog("You can control selected node event with WordCloudLayerDelegate::didWordSelected");
}
}
}
}
示例3: initFire
void CSmeltArmor::initFire()
{
//获取参考位置
CCNode* pNode = (CCNode*)m_ui->findWidgetById("fire_circle");
CCPoint pPos = ccp(pNode->getPositionX()+15, pNode->getPositionY()+75);
if(m_pFire1 == nullptr)
{
CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9010");
pAnimation->setDelayPerUnit(0.15f);
m_pFire1 = CCSprite::create("skill/9010.png");
m_pFire1->setPosition(pPos);
m_pFire1->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
m_pFire1->setVisible(false);
m_pFire1->setScale(1.6f);
pNode->getParent()->addChild(m_pFire1, pNode->getZOrder());
}
if(m_pFire2 == nullptr)
{
CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9011");
pAnimation->setDelayPerUnit(0.15f);
m_pFire2 = CCSprite::create("skill/9011.png");
m_pFire2->setPosition(pPos);
m_pFire2->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
m_pFire2->setVisible(false);
m_pFire2->setScale(1.5f);
pNode->getParent()->addChild(m_pFire2, pNode->getZOrder());
}
}
示例4: insertChild
// helper used by reorderChild & add
void CCNode::insertChild(CCNode* child, int z)
{
unsigned int index = 0;
CCNode* a = m_pChildren->getLastObject();
if (!a || a->getZOrder() <= z)
{
m_pChildren->addObject(child);
}
else
{
CCNode* pNode;
CCMutableArray<CCNode*>::CCMutableArrayIterator it;
for( it = m_pChildren->begin(); it != m_pChildren->end(); it++)
{
pNode = (*it);
if ( pNode && pNode->m_nZOrder > z )
{
m_pChildren->insertObjectAtIndex(child, index);
break;
}
index++;
}
}
child->setZOrder(z);
}
示例5: 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);
}
}
示例6:
void CC3DSprite::visit( void )
{
m_drawOrder = ++g_drawOrder;
// quick return if not visible. children won't be drawn.
if (!m_bVisible) return;
kmGLPushMatrix();
this->transform();
CCNode* pNode = NULL;
unsigned int i = 0;
if(m_pChildren && m_pChildren->count() > 0)
{
sortAllChildren();
// draw children zOrder < 0
ccArray *arrayData = m_pChildren->data;
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if ( pNode && pNode->getZOrder() < 0 )
{
pNode->visit();
}
else
{
break;
}
}
// self draw
this->draw();
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if (pNode)
{
pNode->visit();
}
}
}
else
{
this->draw();
}
// reset for next frame
m_uOrderOfArrival = 0;
kmGLPopMatrix();
}
示例7: searchNewPositionInChildrenForZ
unsigned int CCParticleBatchNode::searchNewPositionInChildrenForZ(int z)
{
unsigned int count = m_pChildren->count();
for( unsigned int i=0; i < count; i++ )
{
CCNode *child = (CCNode *)m_pChildren->objectAtIndex(i);
if (child->getZOrder() > z)
{
return i;
}
}
return count;
}
示例8: getCurrentIndex
void CCParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* newIndex, CCNode* child, int z)
{
bool foundCurrentIdx = false;
bool foundNewIdx = false;
int minusOne = 0;
unsigned int count = m_pChildren->count();
for( unsigned int i=0; i < count; i++ )
{
CCNode* pNode = (CCNode *)m_pChildren->objectAtIndex(i);
// new index
if( pNode->getZOrder() > z && ! foundNewIdx )
{
*newIndex = i;
foundNewIdx = true;
if( foundCurrentIdx && foundNewIdx )
{
break;
}
}
// current index
if( child == pNode )
{
*oldIndex = i;
foundCurrentIdx = true;
if( ! foundNewIdx )
{
minusOne = -1;
}
if( foundCurrentIdx && foundNewIdx )
{
break;
}
}
}
if( ! foundNewIdx )
{
*newIndex = count;
}
*newIndex += minusOne;
}
示例9: visit
void GridEffectSprite::visit()
{
// quick return if not visible. children won't be drawn.
if (!m_bVisible)
{
return;
}
kmGLPushMatrix();
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->beforeDraw();
}
this->transform();
CCNode* pNode = NULL;
unsigned int i = 0;
if(m_pChildren && m_pChildren->count() > 0)
{
sortAllChildren();
// draw children zOrder < 0
ccArray *arrayData = m_pChildren->data;
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if (pNode == m_originalSprite) continue;
if ( pNode && pNode->getZOrder() < 0 )
{
pNode->visit();
}
else
{
break;
}
}
// self draw
this->draw();
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if (pNode == m_originalSprite) continue;
if (pNode)
{
pNode->visit();
}
}
}
else
{
this->draw();
}
// reset for next frame
m_uOrderOfArrival = 0;
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->afterDraw(this);
}
kmGLPopMatrix();
}
示例10: visit
void UILayoutRenderNode::visit()
{
cocos2d::CCSize size = CCDirector::sharedDirector()->getWinSize();
cocos2d::CCPoint cameraOffset = CCDirector::sharedDirector()->getLevelRenderCameraOffset();
float zeye = CCDirector::sharedDirector()->getZEye();
// quick return if not visible
if (!m_bVisible)
{
return;
}
kmGLPushMatrix();
//TODO: don't need change camera everytime
//it costs much time
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLLoadIdentity();
/*
gluLookAt( size.width/2 + cameraOffset.x, size.height/2 + cameraOffset.y, zeye,
size.width/2 + cameraOffset.x, size.height/2 + cameraOffset.y, 0,
0.0f, 1.0f, 0.0f);*/
kmVec3 eye, center, up;
kmVec3Fill( &eye, size.width/2 + cameraOffset.x, size.height/2 + cameraOffset.y, zeye);
kmVec3Fill( ¢er, size.width/2 + cameraOffset.x, size.height/2 + cameraOffset.y, 0 );
kmVec3Fill( &up, 0.0f, 1.0f, 0.0f);
kmMat4 matrixLookup;
kmMat4LookAt(&matrixLookup, &eye, ¢er, &up);
kmGLMultMatrix(&matrixLookup);
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->beforeDraw();
this->transformAncestors();
}
this->transform();
CCNode* pNode = NULL;
unsigned int i = 0;
if(m_pChildren && m_pChildren->count() > 0)
{
// draw children zOrder < 0
ccArray *arrayData = m_pChildren->data;
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if ( pNode && pNode->getZOrder() < 0 )
{
pNode->visit();
}
else
{
break;
}
}
}
// self draw
this->draw();
// draw children zOrder >= 0
if (m_pChildren && m_pChildren->count() > 0)
{
ccArray *arrayData = m_pChildren->data;
for( ; i < arrayData->num; i++ )
{
pNode = (CCNode*) arrayData->arr[i];
if (pNode)
{
pNode->visit();
}
}
}
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->afterDraw(this);
}
kmGLPopMatrix();
}
示例11: InitBG
//.........这里部分代码省略.........
new_rand = RandomInt(1, 7);
for(int j=0; j < poster_rand.size(); j++){
int val = poster_rand[j];
if(val == new_rand){
found = true;
break;
}
}
}while(found);
poster_rand.push_back(new_rand);
}else{
poster_rand.push_back(RandomInt(1, 7));
}
last = 0;
sprintf(name,"ctm_SpacePoster_%02d.png",poster_rand.back());
sprite = CCSprite::createWithSpriteFrameName(name);
sprite->setScale(scale);
m_Parallax2Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i-192.0f, 103.0f);
pNode->addChild(sprite,2,CCPointMake(0.90f,0.0f),m_Parallax2Points[i]);
m_Parallax2->addObject(sprite);
}
else
{
last = 1;
if(retro_rand.size()>0){
int new_rand;
bool found = false;
do{
found = false;
new_rand = RandomInt(1, 6);
for(int j=0; j < retro_rand.size(); j++){
int val = retro_rand[j];
if(val == new_rand){
found = true;
break;
}
}
}while(found);
retro_rand.push_back(new_rand);
}else{
retro_rand.push_back(RandomInt(1, 6));
}
sprintf(name,"ctm_space_Retro%02d.png",(RandomInt(1, 6)));
CCNode *object = getBGObject();
m_Parallax2Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i-128.0f+object->getPositionX(), 103.0f+object->getPositionY());
pNode->addChild(object,object->getZOrder(),CCPointMake(0.90f,0.0f),m_Parallax2Points[i]);
m_Parallax2->addObject(object);
}
//torch
CCNode *object = getBGObject();
m_Parallax3Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i+object->getPositionX(), 103.0f+object->getPositionY());
pNode->addChild(object,object->getZOrder(),CCPointMake(0.90f,0.0f),m_Parallax3Points[i]);
m_Parallax3->addObject(object);
}
}
else
{
m_Parallax2 = NULL;
}
m_Track = CCArray::createWithCapacity(4);
m_Track->retain();
for(int i = 0; i < 4; i++)
{
int r = 2.999f * CCRANDOM_0_1();
switch(r){
default:
case 0:
sprite = CCSprite::create("Space_Panels_01.png");
break;
case 1:
sprite = CCSprite::create("Space_Panels_02.png");
break;
case 2:
sprite = CCSprite::create("Space_Panels_03.png");
break;
}
sprite->setScaleX(scaleX);
sprite->setScaleY(scaleY);
m_TrackPoints[i] = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT);
m_TrackPoints[i].x += (256.0f*i)*scaleX;
m_TrackPoints[i].y += -28.0f*scale;
sprite->setPosition(m_TrackPoints[i]);
m_layer->addChild(sprite,4);
m_Track->addObject(sprite);
/* sprite = CCSprite::create("ctm_256_Front_hazardstripe.png");
sprite->setScaleX(scaleX);
sprite->setScaleY(scaleY);
sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i, 55.0f));
addChild(sprite,4);
*/
}
}