当前位置: 首页>>代码示例>>C++>>正文


C++ CCMutableArray::getObjectAtIndex方法代码示例

本文整理汇总了C++中CCMutableArray::getObjectAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMutableArray::getObjectAtIndex方法的具体用法?C++ CCMutableArray::getObjectAtIndex怎么用?C++ CCMutableArray::getObjectAtIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCMutableArray的用法示例。


在下文中一共展示了CCMutableArray::getObjectAtIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: atlasIndexForChild

	unsigned int CCSpriteBatchNode::atlasIndexForChild(CCSprite *pobSprite, int nZ)
	{
		CCMutableArray<CCNode*> *pBrothers = pobSprite->getParent()->getChildren();
		unsigned int uChildIndex = pBrothers->getIndexOfObject(pobSprite);

		// ignore parent Z if parent is spriteSheet
		bool bIgnoreParent = (CCSpriteBatchNode*)(pobSprite->getParent()) == this;
		CCSprite *pPrevious = NULL;
		if (uChildIndex > 0)
		{
			pPrevious = (CCSprite*)(pBrothers->getObjectAtIndex(uChildIndex - 1));
		}

		// first child of the sprite sheet
		if (bIgnoreParent)
		{
			if (uChildIndex == 0)
			{
				return 0;
			}

			return highestAtlasIndexInChild(pPrevious) + 1;
		}

		// parent is a CCSprite, so, it must be taken into account

		// first child of an CCSprite ?
		if (uChildIndex == 0)
		{
			CCSprite *p = (CCSprite*)(pobSprite->getParent());

			// less than parent and brothers
			if (nZ < 0)
			{
				return p->getAtlasIndex();
			}
			else
			{
				return p->getAtlasIndex() + 1;
			}
		}
		else
		{
			// previous & sprite belong to the same branch
			if ((pPrevious->getZOrder() < 0 && nZ < 0) || (pPrevious->getZOrder() >= 0 && nZ >= 0))
			{
				return highestAtlasIndexInChild(pPrevious) + 1;
			}

			// else (previous < 0 and sprite >= 0 )
			CCSprite *p = (CCSprite*)(pobSprite->getParent());
			return p->getAtlasIndex() + 1;
		}

		// Should not happen. Error calculating Z on SpriteSheet
		assert(0);
		return 0;
	}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例2: update

void CCAnimate::update(ccTime time)
{
	CCMutableArray<CCSpriteFrame*> *pFrames = m_pAnimation->getFrames();
	unsigned int numberOfFrames = pFrames->count();

	unsigned int idx = (unsigned int)(time * numberOfFrames);

	if (idx >= numberOfFrames)
	{
		idx = numberOfFrames - 1;
	}

	CCSprite *pSprite = (CCSprite*)(m_pTarget);
	if (! pSprite->isFrameDisplayed(pFrames->getObjectAtIndex(idx)))
	{
		pSprite->setDisplayFrame(pFrames->getObjectAtIndex(idx));
	}
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:18,代码来源:CCActionInterval.cpp

示例3: lowestAtlasIndexInChild

	unsigned int CCSpriteBatchNode::lowestAtlasIndexInChild(CCSprite *pSprite)
	{
		CCMutableArray<CCNode*> *pChildren = pSprite->getChildren();

		if (! pChildren || pChildren->count() == 0)
		{
			return pSprite->getAtlasIndex();
		}
		else
		{
			return lowestAtlasIndexInChild((CCSprite*)(pChildren->getObjectAtIndex(0)));
		}
	}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例4: ColorString


//.........这里部分代码省略.........
    // アライン設定
    if( baseAlign == TEXT_ALIGN_CENTER_TOP )
    {
        basex = ( ( width - getStringWidth() )/2 );
    }
    
    if( baseAlign == TEXT_ALIGN_RIGHT_TOP )
    {
        basex = width - getStringWidth();
    }
    
    if( baseAlign == TEXT_ALIGN_LEFT_MIDDLE )
    {
        basey = ( ( height - getStringHeight() )/2 );
    }
    
    if( baseAlign == TEXT_ALIGN_CENTER_MIDDLE )
    {
        basex = ( ( width  - getStringWidth()  )/2 );
        basey = ( ( height - getStringHeight() )/2 );
    }
    
    if( baseAlign == TEXT_ALIGN_RIGHT_MIDDLE )
    {
        basex = width - getStringWidth();
        basey = ( ( height - getStringHeight() )/2 );
    }
    
    if( baseAlign == TEXT_ALIGN_CENTER_BOTTOM )
    {
        basex = ( ( width  - getStringWidth()  )/2 );
        basey = height - getStringHeight();
    }
    
    if( baseAlign == TEXT_ALIGN_RIGHT_BOTTOM )
    {
        basex = width - getStringWidth();
        basey = height - getStringHeight();
    }
    
    if( baseAlign == TEXT_ALIGN_LEFT_BOTTOM )
    {
        basey = height - getStringHeight();
    }
    
    float dispx = basex;
    float dispy = basey;
    
    // 返却用のリスト
    CCMutableArray<StringLabel*>* ret = new CCMutableArray<StringLabel*>;
    ret->autorelease();
    
    // ラベルを生成
    for( int i = 0; i < linecnt; i++ )
    {
        CCMutableArray<ColorString*> *list = getStringList( i );
        
        float lh = getStringLineHeight( i );
        float lw = getStringLineWidth( i );
        
        // 下合わせ
        dispy += lh;
        
        for( int j = 0; j < list->count(); j++ )
        {
            ColorString* cstr = list->getObjectAtIndex( j );
            
            // アライン
            if( j == 0 )
            {
                if( cstr->getAlign() == ALIGN_LEFT   ) dispx = 0;
                if( cstr->getAlign() == ALIGN_CENTER ) dispx = ((width-lw)/2);
                if( cstr->getAlign() == ALIGN_RIGHT  ) dispx = width - lw;
            }    
            
            // テキストを設定
            StringLabel* label = cstr->getStrLabel();
            
            label->setAlign( TEXT_ALIGN_LEFT_BOTTOM );
            //label->setPosition( dispx, dispy );
            label->setOffsetX( dispx );
            label->setOffsetY( dispy );
            
            ret->addObject( label );
            
            // ラベルサイズ取得
            CCSize size = label->getContentSize();
            dispx += size.width;
        }
        
        dispx  = basex;
    }
    
    
    return ret;
    
    
    
    
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的CCMutableArray::getObjectAtIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。