// 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; }
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; }
// 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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
//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; }
CCTableViewCell* DataSourceOfHour::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCString *string; if (idx >= 2 && idx <= 25) string = CCString::createWithFormat("%0.2d", idx-2); else string = CCString::createWithFormat(""); CCTableViewCell *cell = table->dequeueCell(); if (!cell) { cell = new CustomTableViewCell(); cell->autorelease(); CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 25.0); label->setColor(ccBLACK); label->setPosition(ccp(WIDTH/2, HIGHT/2)); label->setAnchorPoint(ccp(0.5,0.5)); label->setTag(123); cell->addChild(label); } else { CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123); label->setString(string->getCString()); } return cell; }
CCTableViewCell* S22PicDetail::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCTableViewCell *pCell = table->dequeueCell(); if (!pCell) { pCell = new CCTableViewCell(); pCell->autorelease(); string picName = "S2"+ PersonalApi::convertIntToString(AppDelegate::S2SelectedScene)+ PersonalApi::convertIntToString(AppDelegate::S2LeftSelected)+"Display"+PersonalApi::convertIntToString(idx+1)+".png"; string picNameStr=PersonalApi::getRealImageName(picName.c_str(),"S2BigPic.png").c_str(); CCSprite *pSprite = CCSprite::create(picNameStr.c_str()); pSprite->setAnchorPoint(CCPointZero); pSprite->setTag(123); float pSpriteScale = tableViewBackGroundSp->getContentSize().height/pSprite->getContentSize().height; pSprite->setScale(pSpriteScale); pSprite->setPosition(ccp(0,pSprite->getPosition().y-pSprite->getContentSize().height*pSpriteScale/2)); pCell->addChild(pSprite); } else { CCSprite *pSprite = (CCSprite*)pCell->getChildByTag(123); string picName = "S2"+ PersonalApi::convertIntToString(AppDelegate::S2SelectedScene)+ PersonalApi::convertIntToString(AppDelegate::S2LeftSelected)+"Display"+PersonalApi::convertIntToString(idx+1)+".png"; string picNameStr=PersonalApi::getRealImageName(picName.c_str(),"S2BigPic.png").c_str(); pSprite->setTexture(CCTextureCache::sharedTextureCache()->addImage(picNameStr.c_str())); } return pCell; }
CCTableViewCell* RPGMapItemsMenuLayer::tableCellAtIndex(CCTableView *tableView, unsigned int idx) { CCTableViewCell *cell = tableView->dequeueCell(); if (!cell) { cell = new CCTableViewCell(); cell->autorelease(); } else cell->removeAllChildrenWithCleanup(true); float x = 100; for (int i = 0; i < 4; i++) { int index = idx * 4 + i; if(index >= this->m_itemsList->count()) break; RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(index); CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22); itemBtn->setPosition(ccp(x, 0)); itemBtn->setTag(itemsData->m_dataId); itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside); cell->addChild(itemBtn); x += 200; } return cell; }
CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCLOG("int table cell index:%u",idx); CCTableViewCell *cell = table->dequeueCell(); if (!cell) { cell = new CCTableViewCell(); cell->autorelease(); } cell->removeAllChildrenWithCleanup(true); if (menuArray->count() < idx + 1) { return NULL; } CCString * text = (CCString *)(menuArray->objectAtIndex(idx)); CCLabelTTF * menuText = CCLabelTTF::create(text->getCString(), "", 24); menuText->setAnchorPoint(ccp(0, 0)); menuText->setPosition(ccp(0, 0)); cell->addChild(menuText); return cell; }
CCTableViewCell* MainLayerHerosBaseBody::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCString *string = CCString::createWithFormat("%d", idx); CCTableViewCell *cell = table->dequeueCell(); if (cell == NULL) { cell = new CCTableViewCell(); cell->autorelease(); } else { cell->removeAllChildren(); } cell->addChild(getItemContentByIndex(idx),0,TAG_BaseBody_TABLE_ITEM); //CCLog("CCTableViewCell one"); // } // else // { // //CCLog("refreshItem one"); // CCNode* temp = cell->getChildByTag(TAG_BaseBody_TABLE_ITEM); // refreshItem(temp,idx); // } return cell; }
CCTableViewCell * equipmentRoom:: tableCellAtIndex (CCTableView * table, unsigned int idx) { CCString* string; char tc_label[30]; int contentID = 0; sprintf(tc_label,"%s", equipmentList[idx]->m_name.c_str()); //string = CCString::create(m_buttons[idx].label); string = CCString::create(tc_label); //cout << idx << "script name = " << string->getCString() << endl; //cout << "author1 = " << scriptVector[idx]->authorNames[0] << endl; CCTableViewCell *cell;// = table->dequeueCell(); //if (!cell) { cell = new CustomTableViewCell(); cell->autorelease(); CCSprite *sprite = CCSprite::create("grey_cell.png"); sprite->setAnchorPoint(CCPointZero); sprite->setPosition(ccp(0, 0)); sprite->setScaleX(sfx); sprite->setScaleY(sfy); sprite->setTag(4); cell->addChild(sprite); cell->setObjectID(idx); CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 12.0); label->setPosition(ccp(sprite->boundingBox().size.width/2, sprite->boundingBox().size.height/2)); label->setAnchorPoint(ccp(0.5, 0.5)); //label->setPosition(CCPointZero); //label->setAnchorPoint(CCPointZero); label->setTag(123); cell->addChild(label); //} /*else { CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123); label->setString(string->getCString()); }*/ cout << "cell # " << idx << "title = " << string->getCString() << endl; return cell; }
CCTableViewCell* MainScene::tableCellAtIndex(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-144.png"); sprite->setAnchorPoint(CCPointZero); sprite->setPosition(ccp(0, 0)); sprite->setScaleX(2); cell->addChild(sprite); CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0); label->setPosition(CCPointZero); label->setAnchorPoint(CCPointZero); label->setTag(123); cell->addChild(label); CCMenuItemImage *pBtn = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(MainScene::tableViewSubBtnCallback)); CCMenu* pMenu = CCMenu::create(pBtn, NULL); pBtn->setPosition(ccp(pBtn->getContentSize().width/2,pBtn->getContentSize().height/2)); pMenu->setPosition(CCPointZero); cell->addChild(pMenu, 1); cell->setTag(idx); } else { CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123); label->setString(string->getCString()); } return cell; }
CCTableViewCell* RPGBattleMenu::tableCellAtIndex(CCTableView *tableView, unsigned int idx) { CCTableViewCell *cell = tableView->dequeueCell(); if (!cell) { cell = new CCTableViewCell(); cell->autorelease(); } else cell->removeAllChildrenWithCleanup(true); if(dynamic_cast<RPGSkillBtnData*>(this->m_tableItems->objectAtIndex(idx)) != NULL) { //点击了技能项 RPGSkillBtnData *itemsData = (RPGSkillBtnData*)this->m_tableItems->objectAtIndex(idx); CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_MP)->getCString(), "Arial", 22); itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0)); itemBtn->setTag(itemsData->m_dataId); itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside); cell->addChild(itemBtn); } else if(dynamic_cast<RPGExistingItems*>(this->m_tableItems->objectAtIndex(idx)) != NULL) { //点击了道具项 RPGExistingItems *itemsData = (RPGExistingItems*)this->m_tableItems->objectAtIndex(idx); CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22); itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0)); itemBtn->setTag(itemsData->m_dataId); itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside); cell->addChild(itemBtn); } return cell; }
CCTableViewCell* MessageTableLayer::tableCellAtIndex(CCTableView *table, unsigned int idx){ CCTableViewCell *cell = table->dequeueCell(); if (true){ cell = new CCTableViewCell(); cell->autorelease(); float cellHeight=S_RM->getSizeWithName("dialog_table_cell_size").height; CCPoint middlePoint=S_RM->getRelativePosition("dialog_table_middle", cellHeight); if (m_messageVector->size()==0) { CCSprite* jiazai=CCSprite::createWithSpriteFrameName("jiazai.png"); jiazai->setPosition(middlePoint); jiazai->runAction(CCRepeatForever::create(CCRotateBy::create(2, 360))); cell->addChild(jiazai); }else{ Message* message=(*m_messageVector)[idx]; float cellHeight=S_RM->getSizeWithName("dialog_table_cell_size").height; CCSprite* bg=CCSprite::createWithSpriteFrameName("rank_bg.png"); bg->setPosition(middlePoint); CCLabelTTF* title=CCLabelTTF::create(message->gettitle().c_str(), "KaiTi.ttf",25,S_RM->getSizeWithName("dialog_table_message_title"),kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter); if (message->getisReaded()==1) { title->setColor(ccGRAY); }else{ title->setColor(ccBLUE); title->setFontSize(27); title->enableShadow(CCSizeMake(2, 2), 1, 1); } title->setPosition(S_RM->getRelativePosition("dialog_table_message_title", cellHeight)); bg->addChild(title); cell->addChild(bg); } } return cell; }
CCTableViewCell* S3PracticeScene::tableCellAtIndex(CCTableView *table, unsigned int idx) { // CCString *strCell = CCString::createWithFormat("Practice %d",idx); CCString *strCell = CCString::create(aVectorCellValue[idx].c_str()); CCTableViewCell *pCell = table->dequeueCell(); if (!pCell) { pCell = new CCTableViewCell(); pCell->autorelease(); CCSprite *pSprite = CCSprite::create();//("cellLine.png"); pSprite->setAnchorPoint(CCPointZero); pSprite->setPosition(CCPointZero); pCell->addChild(pSprite); { CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s3FontSize3_macro, s3Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter); pLabel->setPosition(ccp(s3Less2_macro,0)); pLabel->setAnchorPoint(CCPointZero); pLabel->setColor(ccc3(0,0,0)); pLabel->setTag(10); pCell->addChild(pLabel,1); } { CCLabelTTF *pLabel = CCLabelTTF::create("Locked", "Arial",s3FontSize3_macro, s3SizeCellLaterLabel_macro, kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter); pLabel->setPosition(s3Position8_macro(aItem)); pLabel->setAnchorPoint(CCPointZero); pLabel->setColor(ccc3(0,0,255)); pLabel->setTag(10); pCell->addChild(pLabel,1); } } CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10); pLabel->setString(strCell->getCString()); return pCell; }
CCTableViewCell* TableViewTestLayer::tableCellAtIndex(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("HelloWorld.png"); sprite->setScale(0.2f); sprite->setPosition(ccp(60, 60)); sprite->setTag(123); cell->addChild(sprite); CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Arial", 20.0); label->setPosition(ccp(60,10)); label->setTag(456); cell->addChild(label); } else { CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(456); label->setString(string->getCString()); } return cell; }
CCTableViewCell* ListViewLayer::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCTableViewCell *cell = table->dequeueCell(); if (cell == NULL) { cell = new CCTableViewCell(); cell->autorelease(); if (mSource.creator) { CCNode* item = mSource.creator->getItemContentByIndex(idx); // 包裹 CCNode* wraped = CCNode::create(); wraped->setContentSize(item->getContentSize()); wraped->addChild(item,0); // 有个0.5,0.5的偏移 wraped->setPosition(ccp(wraped->getContentSize().width/2,wraped->getContentSize().height/2)); cell->addChild(wraped,0,TAG_LIST_CELL_ITEM_WRAP); }else { CCAssert(false,""); } CCLog("ListViewLayer::tableCellAtIndex ---> create!"); } else { CCLog("ListViewLayer::tableCellAtIndex ---> refesh!"); CCNode* warped = cell->getChildByTag(TAG_LIST_CELL_ITEM_WRAP); CCNode* item = (CCNode*)warped->getChildren()->objectAtIndex(0); if (mSource.creator) { mSource.creator->refreshItem(item,idx); }else { CCAssert(false,""); } } return cell; }
CCTableViewCell * HelloWorld::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx){ CCTableViewCell *cell = table->dequeueCell(); CCLabelTTF *label; if (cell==NULL) { cell = new CCTableViewCell(); label = CCLabelTTF::create("Label", "Courier", 48); cell->addChild(label); label->setTag(TABLE_CELL_LABEL_TAG); label->setAnchorPoint(ccp(0, 0)); cell->setAnchorPoint(ccp(0, 0)); }else{ label = (CCLabelTTF*)cell->getChildByTag(TABLE_CELL_LABEL_TAG); } label->setString(((CCString*)dataArr->objectAtIndex(idx))->getCString()); return cell; }
CCTableViewCell* IOSStoreLayer::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCTableViewCell *cell = table->dequeueCell(); if (cell) { cell->removeAllChildren(); } else { cell = new CCTableViewCell; cell->autorelease(); } //根据标签来初创建不同的cell CCSprite* pDaoju = NULL; if (table->getTag() == kaibaoxiang_node_tableview_tag) { if (idx >= 0 && (int)idx < m_iBaoxiangCellCount) { pDaoju = this->createCellSpr(idx, &m_baoxiangInfoVector.at(idx)); } } else { if (idx >= 0 && (int)idx < m_iBuyStarCellCount) { pDaoju = this->createCellSpr(idx, &m_buystarInfoVector.at(idx)); } } if (pDaoju) { pDaoju->setPosition(CCPointZero); if (idx == 0) { pDaoju->setPosition(ccp(10, 0)); } pDaoju->setAnchorPoint(ccp(0,0)); cell->addChild(pDaoju); } return cell; }
CCTableViewCell* TestList::tableCellAtIndex ( CCTableView* pTable, KDuint uIndex ) { CCTableViewCell* pCell = pTable->dequeueCell ( ); if ( !pCell ) { pCell = CCTableViewCell::create ( ); CCMenuItemFont* pItem = CCMenuItemFont::create ( l_pTestNames [ uIndex ] ); pCell->addChild ( pItem, 0, 1 ); pItem->setPosition ( ccpMid ( cellSizeForTable ( pTable ) ) ); } else { CCMenuItemFont* pItem = (CCMenuItemFont*) pCell->getChildByTag ( 1 ); pItem->setString ( l_pTestNames [ uIndex ] ); } return pCell; }