Esempio n. 1
0
void CSharpTollgate::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	const vector<StageWidget> *data = DataCenter::sharedData()->getStageData()
		->getStageWidgets(m_chapter);
	CStage &stage = m_stageList.at(uIdx);

	for (int i = 0; i < 2; i++)
	{
		CCNode * node = (CCNode*)m_cell->getChildren()->objectAtIndex(i);

		if (node->getTag()==1)
		{
			const StageWidget *widget = nullptr;			
			CCString *strId = CCString::createWithFormat("hero%d",uIdx+1);
			for (int j=0; j<data->size();++j)
			{
				widget = &data->at(j);
				if (widget->widgetId!=""&&widget->widgetId.compare(strId->getCString())==0)
				{				
					CButton *btn =  CButton::create(widget->normalImage.c_str());
					btn->setScaleX(widget->scaleX);
					btn->setScaleY(widget->scaleY);
					btn->setPosition(ccp(100, 80/*btn->boundingBox().size.height*/));  
					btn->setAnchorPoint(ccp(0.5, 0.0));
					btn->setUserData(&m_stageList.at(uIdx));
					btn->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onBattle));
					btn->setTag(1);
					pCell->addChild(btn);
					if (!stage.isOpen)
					{
						btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
// 						btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
					break;
				}
			}
		}
		else if (node->getTag()==2)
		{
			CImageView *image = UICloneMgr::cloneImageView((CImageView*)node);
			if (stage.star>0)
			{		
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("tollgate/star_%d.png",stage.star)->getCString()));
			}
			else
			{
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage("tollgate/star_3.png"));
				image->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			}
			image->setAnchorPoint(ccp(0.5f,0));

			pCell->addChild(image);
		}
	}
	pCell->setVisible(false);
	pCell->setScale(1.15f);
	pCell->runAction(CCSequence::create(CCDelayTime::create(0.1f+0.15f*uIdx),CCShow::create(),CCScaleTo::create(0.05f,1.0f),CCCallFuncN::create(this,callfuncN_selector(CSharpTollgate::heroCall)),nullptr));
}
Esempio n. 2
0
bool CSignLayer::init()
{
	if (BaseLayer::init())
	{
		MaskLayer* lay = MaskLayer::create("CSignLayermask");
		lay->setContentSize(CCSizeMake(2824,640));
		LayerManager::instance()->push(lay);

		m_ui = LoadComponent("Sign.xaml");  //  SelectSkill
		m_ui->setPosition(VCENTER);
		this->addChild(m_ui);
		this->setOpacity(180);

		//背景框
		CImageView* pImageRect = (CImageView*)m_ui->findWidgetById("board_sign");

		//添加一个裁切层
		CCClippingNode* pClip = CCClippingNode::create();
		CImageView* pImage = UICloneMgr::cloneImageView(pImageRect);
		pImage->setAnchorPoint(ccp(0.5f, 0.5f));
		pImage->setPosition(ccp(pImage->getContentSize().width/2, pImage->getContentSize().height/2));
		pClip->setStencil(pImage);
		pClip->setContentSize(pImageRect->getContentSize());
		pClip->setAnchorPoint(pImageRect->getAnchorPoint());
		pClip->setPosition(pImageRect->getPosition());
		pImageRect->getParent()->addChild(pClip, pImageRect->getZOrder()+1);
		m_pClip = pClip;
		
		//展示区图片
		m_show_info_scroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
		m_show_info_scroll->setDirection(eScrollViewDirectionVertical);
		m_show_info_scroll->setBounceable(true);

		m_pInfo1 = (CLabel*)m_ui->findWidgetById("info_1");
		CC_SAFE_RETAIN(m_pInfo1);
		m_pInfo1->removeFromParentAndCleanup(false);
		m_show_info_scroll->getContainer()->addChild(m_pInfo1);
		m_pInfo1->setAnchorPoint(ccp(0, 1));
		CC_SAFE_RELEASE(m_pInfo1);

		m_pInfo2 = (CLabel*)m_ui->findWidgetById("info_2");
		CC_SAFE_RETAIN(m_pInfo2);
		m_pInfo2->removeFromParentAndCleanup(false);
		m_show_info_scroll->getContainer()->addChild(m_pInfo2);
		m_pInfo2->setAnchorPoint(ccp(0, 1));
		CC_SAFE_RELEASE(m_pInfo2);

		updateShowInfoScroll();

		m_show_info_scroll->setVisible(false);

		CCNode* pMaskInfo = (CCNode*)m_ui->findWidgetById("mask_info");
		pMaskInfo->setVisible(false);

		m_pLineEffect = new CLineLightEffect;
		m_pLineEffect->bindUI(m_ui);
		m_pLineEffect->bindRectEffect(pImageRect);
		this->addChild(m_pLineEffect, 999);


		m_pYellowTip = CCSprite::create("sign/lightbox5.png");
		m_pYellowTip->setAnchorPoint(ccp(0.5f, 0.0f));
		m_pYellowTip->setScale(0.8f);
		m_pYellowTip->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCMoveBy::create(0.3f, ccp(0, -10)), CCMoveBy::create(0.3f, ccp(0, 10)))));
		m_ui->addChild(m_pYellowTip, 50);
		m_pYellowTipText = UICloneMgr::cloneLable((CLabel*)m_ui->findWidgetById("day1"));
		m_pYellowTipText->setAnchorPoint(ccp(0.5f, 0.5f));
		m_pYellowTipText->setPosition(ccp(m_pYellowTip->getContentSize().width/2, m_pYellowTip->getContentSize().height/2+12));
		m_pYellowTipText->setScale(1.2f);
		m_pYellowTip->addChild(m_pYellowTipText);
		m_pYellowTip->setVisible(false);

		return true;
	}
	return false;

}