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


C++ CCArray::lastObject方法代码示例

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


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

示例1: kickOut

void Troop::kickOut(Pet* pet) {
    int index = pet->getIndex();
    
    if (index >= cap) return;
    
    CCArray* vlink = (CCArray*)vlinks->objectAtIndex(pet->getVLink());
    int v = vlink->indexOfObject(pet);
    
    vlink->removeObject(pet);
    
    while (vlink->count() > v) {
        Pet* p = (Pet*)vlink->lastObject();
        p->setVLink(index + col);
        vlink->removeLastObject();
        ((CCArray*)vlinks->objectAtIndex(index + col))->insertObject(p, 0);
    }
    
    CCArray* hlink = (CCArray*)hlinks->objectAtIndex(pet->getHLink());
    int h = hlink->indexOfObject(pet);
    
    hlink->removeObject(pet);
    
    while (hlink->count() > h) {
        Pet* p = (Pet*)hlink->lastObject();
        p->setHLink(index + 1);
        hlink->removeLastObject();
        ((CCArray*)hlinks->objectAtIndex(index + 1))->insertObject(p, 0);
    }
    
    pets->replaceObjectAtIndex(index, Pet::createFakePet());
}
开发者ID:Winchy,项目名称:SoulStone,代码行数:31,代码来源:Troop.cpp

示例2: MergeSmallASprite

	//// merge small piece asprite to a big one
	CCNode* UIPicture::MergeSmallASprite(CCSprite* sprite)
	{
		if (!sprite)
			return NULL;

		CCTexture2D* ptexture = RecursiveFindTexture(sprite);
		if (ptexture == NULL)
			return sprite;

		if(sprite->getChildrenCount() == 0)
		{
			return sprite;
		}

		CCArray* secondTextureSprite = CCArray::create();

		while (sprite->getChildrenCount() > 0)
		{
			CCTexture2D* ptexture = RecursiveFindTexture(sprite);

			/// create new batch node which used to store a series of sprites
			CCSpriteBatchNode * pNode = CCSpriteBatchNode::createWithTexture(ptexture);

			CCSize size = sprite->getContentSize();
			CCPoint pt = sprite->getPosition();

			pNode->setContentSize(size);
			pNode->setAnchorPoint(ccp(0.0, 0.0));

			secondTextureSprite->removeAllObjects();
			int i = 0;
			while(sprite->getChildrenCount() > 0)
			{
				CCArray* children = sprite->getChildren();
				CCSprite* s1 = (CCSprite*)(children->lastObject());			
				sprite->removeChild(s1, false);

				if (s1->getTexture() == ptexture)
				{
					pNode->addChild(s1, i--);
				}else
				{
					secondTextureSprite->addObject(s1);
				}
			}

			/// copy second texture sprite to sprite
			CCObject* pTemp;
			CCARRAY_FOREACH(secondTextureSprite, pTemp)
			{
				CCSprite* pPst = (CCSprite*) pTemp;
				sprite->addChild(pPst);
			}

			if (!m_pSpriteNode)
			{
				/// 第一次创建时,取第一个sprite位置为当前m_pSpriteNode的位置
				m_pSpriteNode = CCNode::create();
				m_pSpriteNode->setPosition(pt);
				m_pSpriteNode->setContentSize(size);
				m_pSpriteNode->setAnchorPoint(sprite->getAnchorPoint());

				pNode->setPosition(CCPointZero);
			}else
			{
				/// convert other sprite to local position 
				CCPoint ptOrgio = m_pSpriteNode->getPosition();
				pt = ccpSub(pt , ptOrgio);
				pNode->setPosition(pt);
			}

			m_pSpriteNode->addChild(pNode);	
		}	
开发者ID:niuzb,项目名称:hellopet,代码行数:74,代码来源:UIPicture.cpp

示例3: SimulationSkill

bool BattleCharacter::SimulationSkill(BattleCharacter* pInvoker,CCArray* pTargets)
{	
	CCArray* pEffectTargets =CCArray::createWithCapacity(pTargets->count());
	pEffectTargets->retain();
	bool bCommandSuc = false;
	for(unsigned int index = 0;index<pTargets->count();index++)
	{
		SkillDataLoader* pData = SkillDataLoader::instance();
		int nID = pInvoker->m_nOnUseID;
		int nType = 0;
		pData->GetSkillValue(DATA_SKILL_TYPE,nID,&nType);
		BattleCharacter* pTarget = (BattleCharacter*)pTargets->objectAtIndex(index);
		//判断是否产生伤害
		bool bDamage = (nType == SKILL_TYPE_DAMAGE)||(nType == SKILL_TYPE_DAMAGE_AND_HEALING);
		bool bHealing = (nType == SKILL_TYPE_HEALING)||(nType == SKILL_TYPE_DAMAGE_AND_HEALING);
		if(bDamage&&(!pInvoker->InSameRace(pTarget)))
		{
			int nDamage = BattleCharacter::GetSkillHPDam(pInvoker,pTarget);	
			pTarget->m_nHP += -nDamage;
			pTarget->m_nHPoffset += -nDamage;
			//pTarget->ShowMapDam(nDamage);
			//pTarget->RefreshHPBar();
			bCommandSuc = true;
			AquireExpFromAttack(pInvoker,pTarget);
			if (!pEffectTargets->containsObject(pTarget))
			{
				pEffectTargets->addObject(pTarget);
			}
		}
		else if(bHealing&&pInvoker->InSameRace(pTarget))
		{
			int nHealing = BattleCharacter::GetSkillHPHeal(pInvoker,pTarget);
			pTarget->m_nHP += nHealing;
			pTarget->m_nHPoffset += nHealing;
			bCommandSuc = true;
			AquireExpFromAttack(pInvoker,pTarget);
			if (!pEffectTargets->containsObject(pTarget))
			{
				pEffectTargets->addObject(pTarget);
			}
		}
	}
	if(bCommandSuc)
	{
		CCArray* pAnimations = AnimationManager::instance()->CreateMapSkillAnimations(pInvoker->m_nOnUseID);
		CCAnimation* pMapSkillAnimation = (CCAnimation*)pAnimations->objectAtIndex(0);
		CCSprite* pMapSkillSprite = CCSprite::createWithSpriteFrame(dynamic_cast<CCAnimationFrame*>(pMapSkillAnimation->getFrames()->objectAtIndex(0))->getSpriteFrame());
		CCSprite* pMapSkillBackgroundSprite = NULL;
		CCAnimation* pMapSkillBackgroundAniation  = NULL;
		if (pAnimations->count()>1)
		{
			pMapSkillBackgroundAniation = (CCAnimation*)pAnimations->lastObject();
			pMapSkillBackgroundSprite = CCSprite::createWithSpriteFrame(dynamic_cast<CCAnimationFrame*>(pMapSkillBackgroundAniation->getFrames()->objectAtIndex(0))->getSpriteFrame());
		}
		if (pMapSkillBackgroundSprite!=NULL)
		{
			pMapSkillBackgroundSprite->setPosition(ccp(pInvoker->m_nCommandX,pInvoker->m_nCommandY));
			CharacterStatus::m_pMap->addChild(pMapSkillBackgroundSprite,MAX_LAYER_ZORDER-1,LAYER_MAPSKILLBACKGROUND_ID);
			pMapSkillBackgroundSprite->runAction(CCRepeatForever::create(CCAnimate::create(pMapSkillBackgroundAniation)));
			pMapSkillSprite->setPosition(ccp(pMapSkillBackgroundSprite->getPositionX(),pMapSkillBackgroundSprite->getPositionY()+GetSpriteTextureHeight(pMapSkillBackgroundSprite)));
		}
		else
		{
			pMapSkillSprite->setPosition(ccp(pInvoker->m_nCommandX,pInvoker->m_nCommandY));
		}
		CharacterStatus::m_pMap->addChild(pMapSkillSprite,MAX_LAYER_ZORDER);
		pMapSkillSprite->runAction(CCSequence::create(CCAnimate::create(pMapSkillAnimation),CCCallFuncND::create(pInvoker,callfuncND_selector(BattleCharacter::MapSkillEffectsCallBack),(void*)pEffectTargets),NULL));


	}
	return bCommandSuc;
}
开发者ID:Liang-Shan-Bo,项目名称:SRPG,代码行数:72,代码来源:BattleCharacter.cpp


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