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


C++ CCTableViewCell::addChild方法代码示例

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


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

示例1: tableCellAtIndex

// Hàm này tạo 1 tableview Row để add vào table view
CCTableViewCell* LayerSMS::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx){
    CCTableViewCell *cell = table->dequeueCell();
    StructSMS sms = lstSMS.at(idx);
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        //Time
        CCLabelTTF *labelName = CCLabelTTF::create(sms.content.c_str(), "Helvetica", 16.0);
        labelName->setPosition(ccp(nodeTable->getContentSize().width/2, 20));
		labelName->setAnchorPoint(ccp(0.5, 0.5));
//        labelName->setTag(tag_NameFriend);
        cell->addChild(labelName);
        //Sprite
        CCSprite* line = CCSprite::createWithSpriteFrameName("assest/background_cell.png");
        line->setPosition(ccp(nodeTable->getContentSize().width/2,0));
        line->setScaleX(nodeTable->getContentSize().width/line->getContentSize().width);
        line->setAnchorPoint(ccp(0.5,0));
        cell->addChild(line);
    }
    else
    {
//        CCLabelTTF *label1 = getLabelFromTagID(cell, tag_cellTime);
//        if( label1!=NULL )
//            label1->setString(his.lastUpdateTime.c_str());
//        CCLabelTTF *label2= getLabelFromTagID(cell, tag_cellAmount);
//        if( label2!=NULL )
//            label2->setString(his.amount.c_str());
//        CCLabelTTF *label3 = getLabelFromTagID(cell, tag_cellDetails);
//        if( label3!=NULL )
//            label3->setString(mUtils::getExplainOfTransType(his.transType.c_str()).c_str());
    }
    return cell;
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:34,代码来源:LayerSMS.cpp

示例2: tableCellAtIndex

CCTableViewCell* GameUI_MainTitle::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx)
{
    CCString *string = CCString::createWithFormat("%d", idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCSprite *sprite = CCSprite::create("Icon.png");
        sprite->setAnchorPoint(CCPointZero);
        sprite->setPosition(ccp(0, 0));
        cell->addChild(sprite);
        
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(CCPointZero);
		label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    return cell;
}
开发者ID:bwjdrl2,项目名称:Infinity,代码行数:27,代码来源:GameUI_MainTitle.cpp

示例3: tableCellAtIndex

// Hàm này tạo 1 tableview Row để add vào table view
CCTableViewCell* LayerChangeAvatar::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx){
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        //Chon
        CCSprite* ready = CCSprite::createWithSpriteFrameName("assest/ratio_disable.png");
        ready->setPosition(ccp(15, 100));
        ready->setAnchorPoint(ccp(0, 0));
        cell->addChild(ready);
        //lable chon
        CCLabelTTF *labelChon = CCLabelTTF::create("Chọn", "Helvetica", 14);
        labelChon->setPosition(ccp(40, 100));
        labelChon->setAnchorPoint(ccp(0, 0));
        cell->addChild(labelChon);
        //avatar
        CCSprite* avatar = CCSprite::createWithSpriteFrameName("assest/icon_default.png");
        avatar->setPosition(ccp(0, 0));
        avatar->setAnchorPoint(ccp(0, 0));
        avatar->cocos2d::CCNode::setScale(93/avatar->getContentSize().width, 93/avatar->getContentSize().height);
        cell->addChild(avatar);    }
    else
    {
        //;;;;
    }
    return cell;
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:28,代码来源:LayerChangeAvatar.cpp

示例4: CustomTableViewCell

CCTableViewCell* S11PrepareRes::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell)
    {
        cell = new CustomTableViewCell();
        cell->autorelease();
        if (idx==0)
        {
            selectIndex=0;
        
        }
   
        CCLabelTTF *label = CCLabelTTF::create("点击输入", "Helvetica", 30.0);
        label->setColor(ccBLACK);
        label->setPosition(s11Position8_1_macro(label));
        label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label,101);
        
        CCSprite *pSprite = CCSprite::create("s11CellDivideLine.png");
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        cell->addChild(pSprite,101);
  
    }
    else
    {
        if (selectIndex ==idx)
        {
            if (activeSprite)
            {
                activeSprite->removeFromParentAndCleanup(false);
            }

            
            activeSprite = CCSprite::create("s11Active Bar.png");
            activeSprite->setAnchorPoint(CCPointZero);
            activeSprite->setPosition(CCPointZero);
            cell->addChild(activeSprite,99);
        }
        
         CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        CCString *aString = CCString::createWithFormat("%u",idx+1);
        std::string aStr = aString->m_sString;
        std::map<std::string,std::string>::iterator aIterator = scriptMap.find(aStr);
        std::string aStr2;
        if (aIterator !=scriptMap.end())
        {
            aStr2 = aIterator->second;
        }
        
        label->setString(aStr2.c_str());
  
    }
    
    return cell;
}
开发者ID:liuyuyefz,项目名称:GreTest,代码行数:58,代码来源:S11PrepareResScene.cpp

示例5: CCTableViewCell

CCTableViewCell* S131More::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    
    CCTableViewCell *pCell = table->dequeueCell();
    if (!pCell)
    {
        
        pCell = new CCTableViewCell();
        pCell->autorelease();
        
        CCSprite *pSprite1 = CCSprite::create("S13PRightPoint.png");
        pSprite1->setPosition(ccp(0,90));
        pSprite1->setTag(1010);
        pCell->addChild(pSprite1);
        
        string aStr = rightBigTitle[PersonalApi::convertIntToString(idx+1)]+"        "+rightTime[PersonalApi::convertIntToString(idx+1)];
        const char * labelStr = aStr.c_str();//rightBigTitle[PersonalApi::convertIntToString(idx+1)].c_str();
        float titleFontSize = 20;
        CCSize titleDetailSize = CCSizeMake(500, 30);
        CCLabelTTF *pLabel = CCLabelTTF::create(labelStr, s1FontName_macro, titleFontSize, titleDetailSize, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
        pLabel->setTag(234);
        pLabel->setPosition(ccp(280,180));
        pLabel->setColor(ccBLACK);
        pCell->addChild(pLabel);
        
        const char * labelStr2 = rightDetailTitle[PersonalApi::convertIntToString(idx+1)].c_str();
        float titleFontSize2 =  20;
        CCSize titleDetailSize2 = CCSizeMake(500, 30);
        CCLabelTTF *pLabel2 = CCLabelTTF::create(labelStr2, s1FontName_macro, titleFontSize2, titleDetailSize2, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
        pSprite1->setAnchorPoint(ccp(0.0,1.0));
        pLabel2->setTag(567);
        pLabel2->setPosition(ccp(280,130));
        pLabel2->setColor(ccBLACK);
        pCell->addChild(pLabel2);
        
 
        CCSprite *pSprite2 = CCSprite::create("s131RightWordBottom.png");
        pSprite2->setAnchorPoint(CCPointZero);
        pSprite2->setTag(999);
        pSprite2->setPosition(ccp(0,0));
        pCell->addChild(pSprite2);
    }
    else
    {
      
        
        CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(234);
        pLabel->setString((rightBigTitle[PersonalApi::convertIntToString(idx)]+"        "+rightTime[PersonalApi::convertIntToString(idx)]).c_str());
        
        CCLabelTTF *pLabel2 = (CCLabelTTF*)pCell->getChildByTag(567);
        pLabel2->setString(rightDetailTitle[PersonalApi::convertIntToString(idx)].c_str());
        
    }

    return pCell;
}
开发者ID:Ratel13,项目名称:JinRiCompany,代码行数:56,代码来源:S131More.cpp

示例6: tableCellAtIndex

CCTableViewCell* UIStrengthen::tableCellAtIndex( CCTableView* table, unsigned int idx )
{
	CCTableViewCell* cell = table->cellAtIndex(idx);

	if (!cell)
	{
		cell = new CCTableViewCell();
		cell->autorelease();

		CCSprite* generalNameBGSprite;

		if (idx == 0)
		{
			generalNameBGSprite = CCSprite::create("png/IdleEquipment.png");
		}
		else
		{
			generalNameBGSprite = CCSprite::create("png/GeneralNameBG.png");
		}

		generalNameBGSprite->setAnchorPoint(CCPointZero);
		generalNameBGSprite->setPosition(CCPointZero);
		cell->addChild(generalNameBGSprite);

		if (idx != 0)
		{
			CCLabelTTF* generalNameLabel = CCLabelTTF::create();
			generalNameLabel->setPosition(ccp(generalNameBGSprite->getContentSize().width/2, generalNameBGSprite->getContentSize().height/2));
			
			const char* name = TianXiaDiYi::getTheOnlyInstance()->ansi2utf8(formationManager->generalVector[idx-1]->attribute.name);

			generalNameLabel->setString(name);
			cell->addChild(generalNameLabel);
		}

		CCSprite* generalSelectSprite = CCSprite::create("png/GeneralNameSelect.png");
		generalSelectSprite->setPosition(CCPointZero);
		generalSelectSprite->setAnchorPoint(CCPointZero);
		generalSelectSprite->setTag(8);
		generalSelectSprite->setVisible(false);
		cell->addChild(generalSelectSprite);

		generalSelectSpriteVector.push_back(generalSelectSprite);

		if (idx == formationManager->selectId)
		{
			tableCellHighlight(table, cell);
		}
	}

	return cell;
}
开发者ID:joyfish,项目名称:tianxiadiyi,代码行数:52,代码来源:UIStrengthen.cpp

示例7: tableCellAtIndex

CCTableViewCell* ItemListScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCTableViewCell *cell = table->dequeueCell();

    CCLabelTTF *itemNumberLabel = NULL;
    CCLabelTTF *itemNameLabel = NULL;

    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();

        itemNumberLabel = CCLabelTTF::create("", DefaultFontName, FontSizeNormal);
        itemNumberLabel->setAnchorPoint(ccp(0.0, 0.5));
        itemNumberLabel->setPosition(ccp(kItemNumberLabelMarginLeft, kItemCellHeight / 2));
        itemNumberLabel->setTag(kItemCellTagNumberLabel);
        cell->addChild(itemNumberLabel);

        itemNameLabel = CCLabelTTF::create("", DefaultFontName, FontSizeNormal);
        itemNameLabel->setAnchorPoint(ccp(0.0, 0.5));
        itemNameLabel->setPosition(ccp(kItemNameLabelMarginLeft, kItemCellHeight / 2));
        itemNameLabel->setTag(kItemCellTagNameLabel);
        cell->addChild(itemNameLabel);
    }

    Item item = selectedItem(idx);

    cell->removeChildByTag(kItemCellTagImage);

    itemNumberLabel = (CCLabelTTF *)cell->getChildByTag(kItemCellTagNumberLabel);
    itemNumberLabel->setString(CCString::createWithFormat("%02lld", item.get_id())->getCString());

    CCSprite *itemImage = NULL;
    itemNameLabel = (CCLabelTTF *)cell->getChildByTag(kItemCellTagNameLabel);

    if (item->count > 0) {
        itemImage = CCSprite::createWithSpriteFrameName(item->image.c_str());
        itemNameLabel->setString(item->name.c_str());
    }
    else {
        itemImage = CCSprite::createWithSpriteFrameName(NotFoundItemImage);
        itemNameLabel->setString(MessageNotFoundItemNameText);
    }

    itemImage->setAnchorPoint(ccp(0.0, 0.5));
    itemImage->setPosition(ccp(kItemImageMarginLeft, kItemCellHeight / 2));
    itemImage->setTag(kItemCellTagImage);
    cell->addChild(itemImage);

    return cell;
}
开发者ID:ichiko,项目名称:yamiHikariGame,代码行数:50,代码来源:ItemListScene.cpp

示例8: tableCellAtIndex

CCTableViewCell* MainInnerLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	//CCString *string = (CCString *)mCardList->objectAtIndex(idx);
	CCDictionary *dict = (CCDictionary *)mCardList->objectAtIndex(idx);
	//std::string strCardHeadName(((CCString *)dict->objectForKey("cardHeadImg"))->getCString());
	//strCardHeadName.append(".png");

	std::string strCardHeadImg("art/art_head1/");
	strCardHeadImg.append(((CCString *)dict->objectForKey("cardHeadImg"))->getCString());
	strCardHeadImg.append(".png");

	bool selected = (idx==selectedindex);
    CCSprite *sCard = NULL;
    CCSprite *sSelected = NULL;
	CCTableViewCell *cell = table->dequeueCell();
	if (!cell) {
		cell = new CCTableViewCell();
		cell->autorelease();

//		CCSize size = this->tableCellSizeForIndex(table, idx);

		sSelected = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("card_selected.png"));
		sSelected->setVisible(false);
		sSelected->setTag(121);
		sSelected->setPosition(ccp(2,0));
		sSelected->setAnchorPoint(CCPointZero);
		cell->addChild(sSelected);

		/*sCard = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(strCardHeadName.c_str()));*/
		sCard = CCSprite::create(strCardHeadImg.c_str());
		sCard->setScale(CCDirector::sharedDirector()->getContentScaleFactor()/2);
		sCard->setTag(122);
		sCard->setPosition(ccp(2,0));
		sCard->setAnchorPoint(CCPointZero);
		cell->addChild(sCard);
	}
	else
	{
		sCard = (CCSprite*)cell->getChildByTag(122);
        
        CCTexture2D* tex = CCTextureCache::sharedTextureCache()->addImage(strCardHeadImg.c_str());
        sCard->setTexture(tex);
        sCard->setScale(CCDirector::sharedDirector()->getContentScaleFactor()/2);
        
		sCard->setScale(CCDirector::sharedDirector()->getContentScaleFactor()/2);
        //sCard->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(strCardHeadName.c_str()));
	}

	return cell;
}
开发者ID:crazyit,项目名称:iGame,代码行数:50,代码来源:MainInnerLayer.cpp

示例9: tableCellAtIndex

CCTableViewCell* TanSuoLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCTableViewCell *cell = table->dequeueCell();
	if (cell != NULL)
	{
		cell->removeAllChildren();
	}
	else 
	{
		cell = new CCTableViewCell();
		cell->autorelease();
	}

	if (table->getParent() != NULL)
	{
		CCSize cellSize = tableCellSizeForIndex(table, idx);
		Profession profId = mHeros.at(idx)->getCurrentProperty().profession;

		//head  Profession 1-10
		BaseSprite *headImg = BaseSprite::create(ImageManager::getManager()->getImageData_ProfessionHead(profId).getCurrentImageFile());
		cell->addChild(headImg);
		headImg->setPosition(ccp(cellSize.width/2, 92));

		//menu
		FXScrollMenu *menu = FXScrollMenu::create(
			table->getParent()->convertToWorldSpace(table->getPosition()), table->getViewSize());
		cell->addChild(menu, 1);
		menu->setPosition(ccp(0,0));
		CCMenuItemImage *item = CCMenuItemImage::create(
			"renxing_renwu_touxiang.png",
			"renxing_renwu_touxiang_select.png", 
			"renxing_renwu_touxiang_select.png", 
			this, menu_selector(TanSuoLayer::menuItemClicked_JieFenHeroSelect));
		menu->addChild(item, 0, profId);

		m_lMenuItemList.push_back(item);

		item->setPosition(headImg->getPosition());
		//name
		CCLabelTTF *nameLabel = CCLabelTTF::create(BaseActorPropertyParser::getParser()->getExtraProerty(profId).nameInChinese.c_str()
			, fontStr_kaiti, m_nFontSize);
		cell->addChild(nameLabel);
		nameLabel->setPosition(ccp(headImg->getPositionX()
			, headImg->getPositionY()-headImg->getContentSize().height/2-nameLabel->getContentSize().height/2));
		nameLabel->setColor(ccc3(195, 145, 96));
	}

	return cell;
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:49,代码来源:TanSuoLayer.cpp

示例10: tableCellAtIndex

CCTableViewCell* MyScrollView::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCLOG("idx = %d", idx);
	CCTableViewCell *cell = table->dequeueCell();
	CCSprite *sprite;
	switch(idx)
	{
	case 0:
		sprite = CCSprite::create("bangzhuguanyu/1.png");
		break;
	case 1:
		sprite = CCSprite::create("bangzhuguanyu/2.png");
		break;
	case 2:
		sprite = CCSprite::create("bangzhuguanyu/3.png");
		break;
	case 3:
		sprite = CCSprite::create("bangzhuguanyu/4.png");
		break;
	case 4:
		sprite = CCSprite::create("bangzhuguanyu/5.png");
		break;
	case 5:
		sprite = CCSprite::create("bangzhuguanyu/6.png");
		break;
	case 6:
		sprite = CCSprite::create("bangzhuguanyu/7.png");
		break;
	default:
		break;
	}
	if (!cell) {
		cell = new CCTableViewCell();
		cell->autorelease();
		sprite->setAnchorPoint(CCPointZero);
		sprite->setPosition(ccp(0, 0));
		sprite->setTag(123);
		cell->addChild(sprite);
	}
	else
	{
		cell->removeChildByTag(123);
		sprite->setAnchorPoint(CCPointZero);
		sprite->setPosition(ccp(0, 0));
		sprite->setTag(123);
		cell->addChild(sprite);
	}
	return cell;
}
开发者ID:wjf1616,项目名称:TheMiners,代码行数:49,代码来源:MyScrollView.cpp

示例11: tableCellAtIndex

CCTableViewCell* RankingScene::tableCellAtIndex(CCTableView *table, unsigned int idx) {
	CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCTableViewCell *cell = table->dequeueCell();
    cell = new CCTableViewCell();
    cell->autorelease();
    
    // Player Point
    Player * p = (Player*)players->objectAtIndex(idx);
    CCString *string = CCString::createWithFormat("%d",p->getPoint());

    CCLabelTTF *Pointlabel = CCLabelTTF::create(string->getCString(), "Helvetica", 40);
    Pointlabel->setAnchorPoint(ccp(1, 0));
    Pointlabel->setPosition(ccp(600,0));
    Pointlabel->setTag(123);
    cell->addChild(Pointlabel);
    
    // Player Name
    std::string name = p->getName();

    CCLabelTTF *Namelabel = CCLabelTTF::create(p->getName().c_str(), "Helvetica", 40);
    Namelabel->setAnchorPoint(CCPointZero);
    Namelabel->setPosition(ccp(60, 0));
    cell->addChild(Namelabel);
    
    // Player Rank
    char rankBuf[3];
    sprintf(rankBuf, "Numbers/%i.png", idx+1);
    CCSprite *rank = CCSprite::create(rankBuf);
    rank->setAnchorPoint(CCPointZero);
    rank->setPosition(CCPointZero);
    cell->addChild(rank);
    
    if (idx == 0) {
        int rewardLocal = GameManager::sharedGameManager()->getReward();
        std::string nameLocal = GameManager::sharedGameManager()->getName();
        int pointMax = CCUserDefault::sharedUserDefault()->getIntegerForKey("pointMax");
        if (p->getReward() != 0 && rewardLocal != 0 &&
            p->getName() == nameLocal && p->getPoint() == pointMax) {
            CCMenuItemImage *bt_send_email =
                CCMenuItemImage::create("Present.png","PresentOnClicked.png",
                                        this, menu_selector(RankingScene::reward));
            CCMenu * menu = CCMenu::create(bt_send_email, NULL);
            menu->setPosition(ccp(550, 30));
            cell->addChild(menu);
        }
    }
    return cell;
}
开发者ID:ngocdu,项目名称:AirHockeyAndroid,代码行数:48,代码来源:RankingScene.cpp

示例12: tableCellAtIndex

CCTableViewCell* DebugTestScene::tableCellAtIndex( CCTableView* in_pTable, unsigned int in_idx )
{
    CELL_DATA*  pCellData     = &s_aSelectSceneList[in_idx];
    CCString*   pText         = CCString::create(pCellData->pText);
    CCTableViewCell*    pCell = in_pTable->dequeueCell();
    if( pCell == NULL )
    {
        pCell   = new CCTableViewCell();
        pCell->autorelease();

        CCPoint origin     = CCDirector::sharedDirector()->getVisibleOrigin();

        //  ラベル追加
        {
            CCLabelTTF* pLabel  =
            CCLabelTTF::create( pText->getCString(), "Helvetica", MultiResolution::shared()->getFontSize(s_fontSize_.width) );
            
            pLabel->setPosition(ccp(origin.x, 0));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setTag(100);
            pCell->addChild(pLabel);
        }
    }
    else
    {
        CCLabelTTF* pLabel  = (CCLabelTTF*)pCell->getChildByTag(100);
        pLabel->setString(pText->getCString());
    }
    
    return  pCell;
}
开发者ID:kuronokurujp,项目名称:stg,代码行数:31,代码来源:DebugTestScene.cpp

示例13: tableCellAtIndex

CCTableViewCell* ListViewLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    //CCString *pString = (CCString *)aArray->objectAtIndex(idx);
    const char * str = aVect[idx].c_str();
    CCLOG("%s\n/////////",str);
    CCTableViewCell *pCell = table->dequeueCell();
    if (!pCell) {
        pCell = new CCTableViewCell();
        pCell->autorelease();
       /* CCSprite *pSprite = CCSprite::create("pBackground.png");
        //pSprite->setColor(ccBLUE);
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        pCell->addChild(pSprite);
*/
        CCLabelTTF *pLabel = CCLabelTTF::create(str, "Arial", 20.0,CCSizeMake(table->getContentSize().width, 0), kCCTextAlignmentLeft);
        pLabel->setPosition(CCPointZero);
		pLabel->setAnchorPoint(CCPointZero);
        pLabel->setTag(123);
        pLabel->setColor(ccBLACK);
        //pLabel->setContentSize(CCSizeMake(table->getContentSize().width-60, 120));
        pCell->addChild(pLabel);
    }
    else
    {
        CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(123);
        pLabel->setString(str);
    }


    return pCell;
}
开发者ID:liuyuyefz,项目名称:GreTest,代码行数:32,代码来源:ListViewLayer.cpp

示例14: tableCellAtIndex

CCTableViewCell* MainLayerZhuangBeiBody::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCString *string = CCString::createWithFormat("%d", idx);
	CCTableViewCell *cell = NULL;  //table->dequeueCell();
	if (cell == NULL) 
	{
		cell = new CCTableViewCell();
		cell->autorelease();
	}
	else
	{
		cell->removeAllChildren();
	}
	//
	CCMenuItemImage *itemImage = CCMenuItemImage::create(
		itemFiles[idx].c_str()
		,itemFiles_select[idx].c_str()
		, this, SEL_MenuHandler(&MainLayerZhuangBeiBody::menuItemClicked));
	CCMenu* menu = CCMenu::create();
	cell->addChild(menu, 0, TAG_MENU);
	menu->setPosition(CCPointZero);
	menu->addChild(itemImage, 0, idx);
	itemImage->setPosition(ccp(itemImage->getContentSize().width/2, itemImage->getContentSize().height/2));


	return cell;
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:27,代码来源:MainLayerZhuangBeiBody.cpp

示例15: tableCellAtIndex

//reload가 호출 되거나, 스크롤이 움직여 안보이는 셀이 보여질 때 호출된다. 
CCTableViewCell* MenuScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	//테이블이 사용 중인 셀이 있다면 재활용한다. 테이블 뷰는 똑같은 모양에 데이터만 다른 경우가 많다. 그래서 하나의 셀을 재사용하고 데이터만 바꿔준다.
	CCTableViewCell *cell = table->dequeueCell();

	//datalist에서 데이터를 가져온다. 여기서는 CCString을 했지만, CCObject를 상속받은 커스텀 클래스를 만들어서 여러 정보를 담을 수 있을 것이다.
	CCString* string = (CCString*) datalist->objectAtIndex(idx);

	if (!cell) {
		//커스텀 셀을 이용했는데, 이는 커스텀 셀 부분의 draw 함수를 오버로딩하여 여러가지 효과를 줄 수 있기 때문이다. 이 예제에서는 아무런 추가 내용이 없지만, 이부분을 이용하여 3D리스트 뷰나, 크기가 바뀌는 리스트 뷰 같은 조금 더 다이나믹한 리스트뷰를 만들 수 있을 것 같다. 
		cell = new TableViewCell();
		cell->autorelease();

		CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
		label->setPosition(CCPointZero);
		label->setAnchorPoint(CCPointZero);
		label->setTag(123);
		cell->addChild(label);
	}
	else
	{
		CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
		label->setString(string->getCString());
	}

	return cell;
}
开发者ID:Tingtingyu,项目名称:cocos2dx-scrollbar,代码行数:28,代码来源:MenuScene.cpp


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