Example #1
0
// 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* 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;
}
Example #3
0
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;
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
// 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;
}
//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;
}
void MainLayerZhuangBeiBaseBody::disableAllTouchEnd()
{
    mTableView->setTouchEnabled(true);

    int cellNum = numberOfCellsInTableView(mTableView);
    for (int i=0; i<cellNum; i++)
    {
        CCTableViewCell* cell = mTableView->cellAtIndex(i);
        if (cell)
        {
            CCNode* bg = cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);
            if (bg)
            {
                CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_MENU);
                if (menu)
                {
                    menu->setEnabled(true);
                }
            }
        }
    }

    CCPoint beg = mTableView->getContentOffset();
    if (mOffset.y < beg.y) mOffset.y = beg.y;
    if (mOffset.y > tableCellSizeForIndex(mTableView,0).height*3) mOffset.y = tableCellSizeForIndex(mTableView,0).height*3;
    mTableView->setContentOffset(mOffset);
}
Example #9
0
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;
}
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;
}
Example #11
0
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;
}
Example #12
0
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;
}
void GongJiang_EquipSelect::select()
{
	CCTableViewCell* lastCell = mTableView->cellAtIndex(0);
	if (lastCell)
	{
		BaseSprite* bg = (BaseSprite*)lastCell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);

		bool isFirstIn = false;
		// 先不管是否点击了图片
		if(GameGuideManager::getManager()->isGuideNow(GameGuideManager::GID_GongJiang_QiangHua))
		{
			//GameGuideManager::getManager()->setOneGuideStart(GameGuideManager::GID_GongJiang_SelectZhuangBei);
			//GameGuideManager::getManager()->setOneGuideEnd(GameGuideManager::GID_GongJiang_SelectZhuangBei);
			if (bg)
			{
				CCPoint pos = bg->getParent()->convertToWorldSpace(bg->getPosition());
				GuideLayerBase *guideLayer1 = new GuideLayer_SimpleLayer;
				guideLayer1->init(bg->getContentSize(), ccp(pos.x,pos.y + bg->getContentSize().height / 2)
					, LFStrings::getValue("qiangxuanzezhuangbei"), NULL, false);
				//((GuideLayer_SimpleLayer*)guideLayer1)->setCallBack(this,SEL_CallFunc(&JiuGongGeLayer::GuiDeLayerCallBack));
				CCDirector::sharedDirector()->getRunningScene()->addChild(guideLayer1, 128);
			}
		}
	}

}
void MainLayerHerosBaseBody::disableAllTouchBegin()
{
	mTableView->setTouchEnabled(false);
	int cellNum = numberOfCellsInTableView(mTableView);
	for (int i=0;i<cellNum;i++)
	{
		CCTableViewCell* cell = mTableView->cellAtIndex(i);
		if (cell)
		{
			CCNode* bg = cell->getChildByTag(TAG_BaseBody_TABLE_ITEM);
			if (bg)
			{
				CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_TABLE_HERO_IMG);
				if (menu)
				{
					menu->setEnabled(false);
				}
				menu = (CCMenu*)bg->getChildByTag(TAG_Menu);
				if(menu)
				{
					menu->setEnabled(false);
				}
			}
		}
	}

}
Example #16
0
CCNode* ListViewLayer::getListItemByIndex(int index)
{
	CCTableViewCell* lastCell = mTableView->cellAtIndex(index);
	if (lastCell)
	{
		CCNode* wrap = lastCell->getChildByTag(TAG_LIST_CELL_ITEM_WRAP);
		return (CCNode*)wrap->getChildren()->objectAtIndex(0);
	}
	// 已经释放了
	return NULL;
}
Example #17
0
CCTableViewCell* CCTableViewCellCreator::createNode()
{
    CCTableViewCell* pCell = new CCTableViewCell();
    if(pCell)
    {
        pCell->autorelease();
        return pCell;
    }
    CC_SAFE_DELETE(pCell);
    return NULL;
}
void GongJiang_EquipSelect::tableCellTouched(CCTableView* table, CCTableViewCell* cell)
{
	BaseSprite* bg = (BaseSprite*)cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);
	// 先不管是否点击了图片

	// 先移除上一个点击的
	if (selectedIndex >= 0)
	{
		CCTableViewCell* lastCell = table->cellAtIndex(selectedIndex);
		if (lastCell)
		{
			lastCell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM)->removeChildByTag(TAG_BG_MASK_PIC);
		}
	}
	// 再次选自己,代表取消
	if (selectedIndex == cell->getIdx())
	{
		selectedIndex = -1;
	}
	else
	{
		selectedIndex = cell->getIdx();
		BaseSprite* addEff = BaseSprite::create("mianban_zhuangbei_xiangxi_select.png");
		bg->addChild(addEff,10,TAG_BG_MASK_PIC);
		addEff->setPosition(ccp(bg->getContentSize().width/2,bg->getContentSize().height/2));
	}

	if(selectedIndex < 0)
	{
		mMenuItemMakeSure->setEnabled(false);
	}
	else
	{
		mMenuItemMakeSure->setEnabled(true);
	}
	bool isFirstIn = false;
	// 先不管是否点击了图片
	if(GameGuideManager::getManager()->isGuideNow(GameGuideManager::GID_GongJiang_QiangHua))
	{
		//GameGuideManager::getManager()->setOneGuideStart(GameGuideManager::GID_GongJiang_QhHt);
		GameGuideManager::getManager()->setOneGuideEnd(GameGuideManager::GID_GongJiang_QiangHua);

		if (mMenuItemMakeSure)
		{
			CCPoint pos =  mMenuItemMakeSure->getParent()->convertToWorldSpace(mMenuItemMakeSure->getPosition());
			GuideLayerBase *guideLayer1 = new GuideLayer_SimpleLayer;
			guideLayer1->init(mMenuItemMakeSure->getContentSize(),pos
				, LFStrings::getValue("DingjiQueding"), NULL, false);
			//((GuideLayer_SimpleLayer*)guideLayer1)->setCallBack(this,SEL_CallFunc(&JiuGongGeLayer::GuiDeLayerCallBack));
			CCDirector::sharedDirector()->getRunningScene()->addChild(guideLayer1, 128);
		}
	}
}
//定制每个cell的内容
CCTableViewCell* FightInfoLayer::tableCellAtIndex(CCTableView *table, unsigned int idx) {
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    cell -> removeAllChildren();
    FightItemLayer *layer = FightItemLayer::create();
    layer -> setInfo(gameinfo[idx]);
    cell -> addChild(layer);
    return cell;
}
Example #20
0
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;
}
Example #21
0
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;
}
Example #22
0
void DebugTestScene::tableCellTouched( CCTableView* in_pTable, CCTableViewCell* in_pCell )
{
    //  タッチしたシーンに遷移する。
    unsigned int    idx = in_pCell->getIdx();
    CCTableViewCell*    pCell = in_pTable->dequeueCell();
    if( pCell )
    {
        CCLabelTTF* pLabel  = (CCLabelTTF*)pCell->getChildByTag(100);
        pLabel->setFontFillColor(ccc3(255, 0, 0));
    }
    
    CCDirector* pDirector   = CCDirector::sharedDirector();
    pDirector->replaceScene((*s_aSelectSceneList[idx].pScene)());
}
Example #23
0
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;
}
Example #24
0
void CCTableViewCellCreator::setAttribute(CCNode* pNode, const char* strName, const char* strValue, bool bCache)
{
    CCTableViewCell* pTableViewCell = (CCTableViewCell*)pNode;
    if(bCache)
        mAttrMap[strName] = strValue;

    else
    {
        if(strcmp(strName, "index") == 0)
            pTableViewCell->setObjectID(ccXmlAttrParse::toInt(strValue));

        else
            CCNodeCreator::setAttribute(pNode, strName, strValue, bCache);
    }
}
void MainLayerHerosBaseBody::menuItemClicked_heroImg(CCObject* pSender)
{
	CCTableViewCell *cell = (CCTableViewCell*)((CCMenuItemSprite*)pSender)->getParent()->getParent()->getParent();
	int idx = cell->getIdx();
	AddFriendUI *layer = AddFriendUI::create();
	layer->ignoreAnchorPointForPosition(false);
	layer->setAnchorPoint(CCPointZero);
	layer->setPosition(CCPointZero);
	layer->setProfessionId(mHerosVec[idx]->getActorType());
	layer->setMenuShow(true,false);
	CCDirector::sharedDirector()->getRunningScene()->addChild(layer,1024);
	

	
}
Example #26
0
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;
}
Example #27
0
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;
}
Example #28
0
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;
    
    
}
void MainLayerZhuangBeiBody::selectAtIndex(unsigned int index)
{
	// 0 是第一个  所有装备
	CCTableViewCell* currentCell = tableView->cellAtIndex(index);
	CCTableViewCell* lastCell = tableView->cellAtIndex(selectedIndex);

	//if (selectedIndex != index)
	{
		if (lastCell!=NULL)
		{
			CCMenuItemImage* itemImage = (CCMenuItemImage*)lastCell->getChildByTag(TAG_MENU)->getChildByTag(lastCell->getIdx());
			int idx = itemImage->getTag();
			itemImage->initWithNormalImage(
				itemFiles[idx].c_str()
				,itemFiles_select[idx].c_str()
				,NULL, this, menu_selector(MainLayerZhuangBeiBody::menuItemClicked));
		}

		if (currentCell!=NULL)
		{
			CCMenuItemImage* itemImage = (CCMenuItemImage*)currentCell->getChildByTag(TAG_MENU)->getChildByTag(currentCell->getIdx());
			int idx = itemImage->getTag();
			itemImage->initWithNormalImage(
				itemFiles_select[idx].c_str()
				,itemFiles[idx].c_str()
				,NULL, this, menu_selector(MainLayerZhuangBeiBody::menuItemClicked));
		}

		selectedIndex = index;

		BaseLayer* content = createContentAtIndex(index);

		if (selectedContaint)
		{
			selectedContaint->removeFromParent();
		}
		if (content)
		{
			container->addChild(content);
			content->setPosition(ccp(0,0));
		}
		selectedContaint = content;
	}
}
Example #30
0
void CCTableView::reloadData()
{
    m_eOldDirection = kCCScrollViewDirectionNone;
    CCObject* pObj = NULL;
    CCARRAY_FOREACH(m_pCellsUsed, pObj)
    {
        CCTableViewCell* cell = (CCTableViewCell*)pObj;

        if(m_pTableViewDelegate != NULL) {
            m_pTableViewDelegate->tableCellWillRecycle(this, cell);
        }

        m_pCellsFreed->addObject(cell);
        cell->reset();
        if (cell->getParent() == this->getContainer())
        {
            this->getContainer()->removeChild(cell, true);
        }
    }