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


C++ CCArray类代码示例

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


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

示例1: adjustPostionAndScale

void HRootLayer::adjustPostionAndScale(CCNode* node, float scaleX, float scaleY) {
    
    for (int i = 0; i < m_pIgnoreNodeArr->count(); i ++) {
        CCNode* node = dynamic_cast<CCNode*>(m_pIgnoreNodeArr->objectAtIndex(i));
        if (node) {
            node->setScaleX(scaleX);
            node->setScaleY(scaleY);
        }
    }
    
    CCArray *children = node->getChildren();
    if (children) {
        for (int i = children->count() - 1; i >= 0; --i) {
            CCNode *child = (CCNode *)children->objectAtIndex(i);
            if (!m_pIgnoreNodeArr->containsObject(child)) {
                
                CCPoint pos = child->getPosition();
                child->setPosition(ccp(pos.x * scaleX, pos.y * scaleY));
                
            }
        }
    }

}
开发者ID:hyizsg,项目名称:mytest1st,代码行数:24,代码来源:RootLayer.cpp

示例2: endZoom

void EXZoomController::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent){
    bool multitouch = _touchesDic->count() > 1;
	if (multitouch) {
        CCArray* keys = _touchesDic->allKeys();
        CCTouch *touch1 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
		CCTouch *touch2 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(1))->getCString());
        
		CCPoint pt1 = touch1->getLocationInView();
		CCPoint pt2 = touch2->getLocationInView();
		
		endZoom(pt1, pt2);
		
		//which touch remains?
        //		if (touch == touch2)
        //			beginScroll(_node->convertToNodeSpace(touch1->getLocation()));
        //		else
        beginScroll(_node->convertToNodeSpace(touch2->getLocation()));
	} else {
        CCArray* keys = _touchesDic->allKeys();
        CCTouch *touch = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
        recordScrollPoint(touch);
		
        CCPoint pt = _node->convertToNodeSpace(touch->getLocation());
		endScroll(pt);
        
        //handle double-tap zooming
        //        if (zoomOnDoubleTap /**&& [touch tapCount] == 2*/)
        //            handleDoubleTapAt(pt);
	}
	
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++){
        CCTouch* pTouch = (CCTouch*)(*iter);
        _touchesDic->removeObjectForKey(CCString::createWithFormat("%d",pTouch->getID())->getCString());
    }
}
开发者ID:aquariusgx,项目名称:coc,代码行数:36,代码来源:EXZoomController.cpp

示例3: tileCoordForPosition

CCArray* CollisionEngine::getSurroundingTilesAtPosition(CCPoint position,
		CCTMXLayer *layer) {

	CCPoint plPos = tileCoordForPosition(position);
	CCArray *gids = CCArray::create();

	for (int i = 0; i < 9; i++) {
		int c = i % 3;
		int r = (int) (i / 3);
		CCPoint tilePos = ccp(plPos.x + (c - 1), plPos.y + (r - 1));
		// fall into a hole
		if (tilePos.y > (map->getMapSize().height - 1)) {

			// kill the enemy here

			//this->gameOver(false);
			return NULL;
		}

		int tgid = layer->tileGIDAt(tilePos);

		CCRect tileRect = tileRectFromTileCoords(tilePos);

		CCDictionary *tileDict = CCDictionary::create();

		CCXNumericData *tilePosData = CCXNumericData::create();
		CCXNumericData *tgidData = CCXNumericData::create();
		CCXNumericData *rectOrgXData = CCXNumericData::create();
		CCXNumericData *rectOrgYData = CCXNumericData::create();

		tilePosData->setPoint(tilePos);
		tgidData->setIntValue(tgid);
		rectOrgXData->setFloatValue(tileRect.origin.x);
		rectOrgYData->setFloatValue(tileRect.origin.y);
		tileDict->setObject(tgidData, "gid");
		tileDict->setObject(rectOrgXData, "x");
		tileDict->setObject(rectOrgYData, "y");
		tileDict->setObject(tilePosData, "tilePos");

		gids->addObject(tileDict);
	}

	gids->removeObjectAtIndex(4);
	gids->insertObject(gids->objectAtIndex(2), 6);
	gids->removeObjectAtIndex(2);
	gids->exchangeObjectAtIndex(4, 6);
	gids->exchangeObjectAtIndex(0, 4);

	return gids;

}
开发者ID:munhra,项目名称:platform-game-engine,代码行数:51,代码来源:CollisionEngine.cpp

示例4: dictionary_Value

static void dictionary_Value(CCDictionary * aDict, const cocos2d::ValueMap & value)
{
    cocos2d::ValueMap::const_iterator beg = value.begin();
    cocos2d::ValueMap::const_iterator end = value.end();
    for (; beg != end; ++beg)
    {
        const std::string & key = (*beg).first;
        const cocos2d::Value & v = (*beg).second;
        if (v.getType() == Value::Type::MAP)
        {
            CCDictionary * d = new CCDictionary();
            d->init();
            dictionary_Value(d, v.asValueMap());
            aDict->setObject(d, key);
            d->release();
        }
        else if (v.getType() == Value::Type::VECTOR)
        {
            CCArray * a = new CCArray();
            a->init();
            array_Value(a, v.asValueVector());
            aDict->setObject(a, key);
            a->release();
        }
        else
        {
            CCString * str = new CCString();
            if (v.getType() == Value::Type::DOUBLE)
                str->initWithFormat("%f", v.asDouble());
            else
                str->initWithFormat("%s", v.asString().c_str());
            aDict->setObject(str, key);
            str->release();
        }
    }
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:36,代码来源:YHDataManagerImp.cpp

示例5: loadCardsFromXml

void CardScene::loadCardsFromXml()
{
	TiXmlDocument doc;

	//list of card for scroll layer init
	CCArray* cardList = CCArray::create();

	if ( doc.LoadFile(CARDS_XML) )
	{
		TiXmlElement* cards_tag = doc.FirstChildElement();
		TiXmlElement* card_tag = cards_tag->FirstChildElement();
		
		while ( card_tag )
		{
			int number = 0; 
			card_tag->QueryIntAttribute("number", &number);

			const char* path = card_tag->Attribute("path");
			const char* description_id = card_tag->Attribute("description_id");

			//TODO: load description from L10n(Localization) file with description_id

			//create card and add to card list
			Card* card = Card::create(number, path, description_id);
			cardList->addObject( card );
			
			card_tag = card_tag->NextSiblingElement();
		}
	}


	m_pScrollList = CCScrollLayer::create(cardList);
	m_pScrollList->setPosition( ccp(0, 0) );
	addChild( m_pScrollList );

}
开发者ID:MazurenkoZhenya,项目名称:evolution,代码行数:36,代码来源:CardScene.cpp

示例6: CCArray

void Obstacle::SpawnCrow(int xOffset)
{
    CCArray *allFrames = new CCArray();
    for (int i = 0 ; i <= 14 ; i++)
    {
        char fn[64];
        sprintf(fn, "Fly00%d.png" , i );
        allFrames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fn));
    }
    
    CCAnimation *crowAnim = CCAnimation::createWithSpriteFrames(allFrames, 0.04f * 1);
    CCAction *crowAction = CCRepeatForever::create(CCAnimate::create(crowAnim));
    crowAction->retain();
    
    obstacleSprite = CCSprite::createWithSpriteFrameName("Fly000.png");
    obstacleSprite->setPosition(ccp(winSize.width + xOffset * SPAWN_OFFSET  , winSize.height - obstacleSprite->getContentSize().height));
    this->addChild(obstacleSprite);
    
    obstacleSprite->runAction(crowAction);
    moveOnce = true;
//    obstacleSprite->runAction(CCSequence::createWithTwoActions(CCMoveTo::create(1,
//                                                                                ccp( winSize.width - obstacleSprite->getContentSize().width , obstacleSprite->getPosition().y)),
//                                                               CCCallFunc::create(this, callfunc_selector(Obstacle::MoveCrow))));
}
开发者ID:jojizaidi,项目名称:Gnome,代码行数:24,代码来源:Obstacle.cpp

示例7: CCDICT_FOREACH

void BmVList::ShowContents()
{
	clt->setString(g_chara->m_sName.c_str());

	// <ÊôÐÔ
	CCDictElement*	 pCde = NULL;
	string			 t_name;
	CCLabelBMFont*	 t_clbm = NULL;

	int ti = 0;
	CCDICT_FOREACH(m_cdBmNum,pCde){
		t_name = pCde->getStrKey();
		t_clbm = (CCLabelBMFont*) pCde->getObject();

		string tsMai = CCString::createWithFormat("%d",g_chara->getvalue(t_name))->getCString();
		if(ti > 3 && ti < 14){
			int ti = g_chara->getFixValue(t_name) - g_chara->getvalue(t_name);
			string tsMid;
			ti>0?tsMid="+":tsMid="";
			string tsAto =  CCString::createWithFormat("%d",ti)->getCString();
			t_clbm->removeAllChildren();
			t_clbm->setString((tsMai + tsMid + tsAto).c_str());

			CCArray* pArray = t_clbm->getChildren();
			CCLog(">[BmVList] %s - length:%d", tsMai.c_str(), tsMai.length());
			for(int tfi = tsMai.length(); tfi < pArray->count(); ++tfi){
				CCSprite* tcs = (CCSprite*) pArray->objectAtIndex(tfi);
				tcs->setColor(ccRED);
			}

		}else{
			t_clbm->setString(tsMai.c_str());
		}
		++ti;
		
	}
开发者ID:steinkrausls,项目名称:cocotd,代码行数:36,代码来源:BmVList.cpp

示例8: CCArray

CCAnimation* AnimationManager::createHeroMovingAnimationByDirection(HeroDirection direction)
{
	CCTexture2D *heroTexture = CCTextureCache::sharedTextureCache()->addImage("Hero_image.png");
	CCSpriteFrame *frame0, *frame1, *frame2;
	CCArray* animFrames ;
	//第二个参数表示显示区域的x, y, width, height,根据direction来确定显示的y坐标
	
	
	frame0 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*0, eSize*direction, eSize, eSize));
	frame1 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*1, eSize*direction, eSize, eSize));

	
	 animFrames = new CCArray(2);
	animFrames->addObject(frame0);
	animFrames->addObject(frame1);
	
	

	CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.09f);

	animFrames->release();
	
	return animation;
}
开发者ID:fordream,项目名称:strangeAdventure,代码行数:24,代码来源:AnimationManager.cpp

示例9: ccp

//构造函数
Ship::Ship()
{
    this->speed = 220;
    this->bulletSpeed = 900;
    this->HP = 5;
    this->bulletTypeValue = 1;
    this->bulletPowerValue = 1;
    this->throwBombing = false;
    this->canBeAttack = true;
    this->isThrowingBomb = false;
    this->zOrder = 3000;
    this->maxBulletPowerValue = 4;
    this->appearPosition = ccp(160, 60);
    this->hurtColorLife = 0;
    this->active = true;
    this->timeTick = 0;

    this->initWithSpriteFrameName("ship01.png");
    this->setTag(zOrder);
    this->setPosition(this->appearPosition);


    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    CCSpriteFrame *frame0 = cache->spriteFrameByName("ship01.png");
    CCSpriteFrame *frame1 = cache->spriteFrameByName("ship02.png");
    CCArray *frames = CCArray::createWithCapacity(2);
    frames->addObject(frame0);
    frames->addObject(frame1);
    CCAnimation *animation = CCAnimation::createWithSpriteFrames(frames, 0.1f);
    CCAnimate *animate = CCAnimate::create(animation);
    this->runAction(CCRepeatForever::create(animate));

    this->schedule(schedule_selector(Ship::shoot),0.2f);

    this->born();
}
开发者ID:fordream,项目名称:wanghe-project,代码行数:37,代码来源:Ship.cpp

示例10: ASSERT

//////////////////////////////////////////////////////////////////////////
//called when level active
//////////////////////////////////////////////////////////////////////////
void LevelLayer::onActiveLayer(sActiveLevelConfig& config)
{
	//
	this->setTouchEnabled(true);
	//
	CCDirector::sharedDirector()->setLevelRenderCameraOffset(ccp(0,0));

	//send active event to children
	CCArray* children = this->getChildren();
	if (children)
	{
		int childrenCount = children->count();
		for (int i = 0; i < childrenCount; ++i)
		{
			CCNode* child = (CCNode* )children->objectAtIndex(i);
			ASSERT(child != NULL, "child is NULL");

			BaseListener* listener = LevelLayer::sGetListenerByTag(child->getTag());
			if (listener)
			{
				listener->HandleLayerActiveEvent(child, &config);
			}			
		}
	}

	if(m_pObjectsLayer != NULL)
	{
		/*CCNode* pNode = getSpriteSeer();
		if(pNode != NULL)
		{
		BaseListener* listener = LevelLayer::sGetListenerByTag(pNode->getTag());
		listener->HandleLayerActiveEvent(pNode, &config);
		}*/

		CCArray* children = m_pObjectsLayer->getChildren();
		if (children)
		{
			int childrenCount = children->count();
			for (int i = 0; i < childrenCount; ++i)
			{
				CCNode* child = (CCNode* )children->objectAtIndex(i);
				ASSERT(child != NULL, "child is NULL");

				BaseListener* listener = LevelLayer::sGetListenerByTag(child->getTag());
				if (listener)
				{
					listener->HandleLayerActiveEvent(child, &config);
				}				
			}
		}

	}

	//get other players
	//OnlineNetworkManager::sShareInstance()->sendGetOtherPlayersMessage();
}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:59,代码来源:LevelLayer.cpp

示例11: tableCellSizeForIndex

 virtual CCSize tableCellSizeForIndex(CCTableView *table, unsigned int idx)
 {
     if (NULL != table )
     {
         int nHandler = table->getScriptHandler(CCTableView::kTableCellSizeForIndex);
         if (0 != nHandler)
         {
             CCArray* resultArray = CCArray::create();
             if (NULL != resultArray)
             {
                 CCLuaEngine::defaultEngine()->executeTableViewEvent(CCTableView::kTableCellSizeForIndex, table,&idx,resultArray);
                 CCAssert(resultArray->count() == 2, "tableCellSizeForIndex Array count error");
                 CCDouble* width  = dynamic_cast<CCDouble*>(resultArray->objectAtIndex(0));
                 CCDouble* height = dynamic_cast<CCDouble*>(resultArray->objectAtIndex(1));
                 if (NULL != width && NULL != height)
                 {
                     return CCSizeMake((float)width->getValue(), (float)height->getValue());
                 }
             }
         }
     }
     
     return CCSizeMake(0,0);
 }
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:24,代码来源:lua_cocos2dx_extensions_manual.cpp

示例12: switch

void GameScene::operateAllScheduleAndActions(cocos2d::CCNode* node, OperateFlag flag)
{
	if(node->isRunning())
	{
		switch(flag){
		case k_Operate_Pause:
			node->pauseSchedulerAndActions();
			break;
		case k_Operate_Resume:
			node->resumeSchedulerAndActions();
			break;
		default:
			break;
		}
		CCArray* array = node->getChildren();
		if(array != NULL && array->count() > 0)
		{
			CCObject* iterator;
			CCARRAY_FOREACH(array, iterator)
			{
				CCNode* child = (CCNode*)iterator;
				this->operateAllScheduleAndActions(child, flag);
			}
		}
开发者ID:hzfeibao,项目名称:fish,代码行数:24,代码来源:GameScene.cpp

示例13: executeAccelerometerEvent

int CCLuaEngine::executeAccelerometerEvent(CCLayer* pLayer, CCAcceleration* pAccelerationValue)
{
    m_stack->clean();
    CCLuaValueDict event;
    event["name"] = CCLuaValue::stringValue("changed");
    event["x"] = CCLuaValue::floatValue(pAccelerationValue->x);
    event["y"] = CCLuaValue::floatValue(pAccelerationValue->y);
    event["z"] = CCLuaValue::floatValue(pAccelerationValue->z);
    event["timestamp"] = CCLuaValue::floatValue(pAccelerationValue->timestamp);

    m_stack->pushCCLuaValueDict(event);

    CCArray *listeners = pLayer->getAllScriptEventListeners();
    CCScriptHandlePair *p;
    for (int i = listeners->count() - 1; i >= 0; --i)
    {
        p = dynamic_cast<CCScriptHandlePair*>(listeners->objectAtIndex(i));
        if (p->event != ACCELERATE_EVENT || p->removed) continue;
        m_stack->copyValue(1);
        m_stack->executeFunctionByHandler(p->listener, 1);
        m_stack->settop(1);
    }
    return 0;
}
开发者ID:yinjimmy,项目名称:mini-q,代码行数:24,代码来源:CCLuaEngine.cpp

示例14: callback

void INSPayment_iOS::loadProducts(inewsoft::ol::LoadProductCallback callback)
{
    if(!this->productTable.empty() && productsState == inewsoft::ol::kProductsStateLoaded)
    {
        callback(true);
        return;
    }
    else if(this->productsState == inewsoft::ol::kProductsStateLoading)
    {
        this->loadProductCallback = callback;
        return;
    }
    
    /// loald product from developer server firstly
    this->productsState = inewsoft::ol::kProductsStateLoading;
    Payment::loadProducts([this, callback](bool succeed){
        if(succeed) {
            INSStore::sharedStore()->registerTransactionObserver(this);
            CCArray* productsId = new CCArray();
            productsId->autorelease();
            
            for(auto iter = this->productTable.begin(); iter != this->productTable.end(); ++iter)
            {
                productsId->addObject(newCCString(iter->second.id.c_str()));
            }
            
            this->loadProductCallback = callback;
            INSStore::sharedStore()->loadProducts(productsId, this);
        }
        else {
            this->productsState = inewsoft::ol::kProductsStateUnload;
            callback(false);
            
        }
    });
}
开发者ID:xubingyue,项目名称:libxstudio365,代码行数:36,代码来源:INSPayment_iOS.cpp

示例15: transTile

void GameLayer::transTile(GridTile *tileA, GridTile *tileB, SEL_CallFuncND sel)
{
    if (!tileA->getCanPutFruit() || !tileB->getCanPutFruit()) return;
    
    // clear the prompt tiles actions
    if(this->getBLL()->getBox()->getPromptTiles())
    {
        int count = this->getBLL()->getBox()->getPromptTiles()->count();
        for (int i=0; i<count; i++) {
            CCArray* aComb = (CCArray*)this->getBLL()->getBox()->getPromptTiles()->objectAtIndex(i);
            GridTile* aTile = (GridTile*)aComb->objectAtIndex(0);
            GridTile* bTile = (GridTile*)aComb->objectAtIndex(1);
            GridTile* cTile = (GridTile*)aComb->objectAtIndex(2);
            aTile->stopItemActionByTag(kPromptMatchTag);
            bTile->stopItemActionByTag(kPromptMatchTag);
            cTile->stopItemActionByTag(kPromptMatchTag);
            aTile->getFruitItem()->getItemBG()->setScale(kTileScaleFactor);
            bTile->getFruitItem()->getItemBG()->setScale(kTileScaleFactor);
            cTile->getFruitItem()->getItemBG()->setScale(kTileScaleFactor);
        }
    }
    // unschedule prompt time
    this->unschedule(schedule_selector(GameLayer::promptMatch));
    
    this->getBLL()->getBox()->setLock(true);
    CCFiniteTimeAction* actionA = CCSequence::create(CCMoveTo::create(kMoveTileTime, tileB->getFruitItem()->getItemBG()->getPosition()),
                                                     CCCallFuncND::create(this, sel, tileA),
                                                     NULL);
    CCFiniteTimeAction* actionB = CCSequence::create(CCMoveTo::create(kMoveTileTime, tileA->getFruitItem()->getItemBG()->getPosition()),
                                                     CCCallFuncND::create(this, sel, tileB),
                                                     NULL);
    tileA->getFruitItem()->getItemBG()->runAction(actionA);
    tileB->getFruitItem()->getItemBG()->runAction(actionB);
    
    tileA->transWith(tileB);
}
开发者ID:lioneltsai,项目名称:fruitCrush,代码行数:36,代码来源:GameLayer.cpp


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