示例#1
0
void CHandBookHeroLayer::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
	//先克隆外框条
	CLayout *pLay = UICloneMgr::cloneLayout(m_pCellBlank);

	//对应数据
	AtlasIns *pAtlasIns = m_AtlasResponse.mutable_atlas_list()->Mutable(uIdx);

	//赋值
	for (unsigned int i=1; i<=10; i++)
	{
		CCNode *child = pLay->getChildByTag(i);
		pLay->removeChild(child);
		child->setTag(i);
		pCell->addChild(child);
		pCell->setTag(uIdx);
	}

	//1-活动底板
	{
		CImageView* pBoard = dynamic_cast<CImageView*>(pCell->getChildByTag(1));
		pBoard->setTouchEnabled(true);
		pBoard->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickBlank));

		if ( uIdx==m_iSelectIndex )
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_2.png"));
		}
		else
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_1.png"));
		}
	}

	//2-组合名字
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(2));
	}

	//3-//组合描述
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(3));
	}

	//4-礼品背景
	//5-礼品
	//10-文字
	{
		CImageView* pGiftBg = dynamic_cast<CImageView*>(pCell->getChildByTag(4));
		CImageView* pGift = dynamic_cast<CImageView*>(pCell->getChildByTag(5));
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(10));

		pLabel->setVisible(false);
		pGift->stopAllActions();

		//奖励领取标志 0未领取(不可领取),1未领取(可领取状态),2 已领取
		switch (pAtlasIns->get_prize())
		{
		case 0:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));

			}break;
		case 1:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				ResetAnchorPointAndKeepSamePos(pGift, CCPointCenter);
				pGift->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 0.75f), CCScaleTo::create(0.3f, 0.7f))));

			}break;
		case 2:
			{
				pGiftBg->setVisible(false);
				pGift->setVisible(false);
				pLabel->setVisible(true);
			}break;
		default:
			break;
		}
	}


	//7-进度条
	//8-进度数字
	//9-进度图标
	{
		CProgressBar* pProgress = dynamic_cast<CProgressBar*>(pCell->getChildByTag(7));

		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(8));
		pLabel->setTouchEnabled(true);
		pLabel->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));

		CImageView* pIcon = dynamic_cast<CImageView*>(pCell->getChildByTag(9));
		pIcon->setTouchEnabled(true);
		pIcon->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));
	}


	//收集列表
	CCPoint pPos(80, 54);
	int iGapX = 94;
	initListCellIcon( pAtlasIns, pPos, iGapX, pCell );

}