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


C++ CLayout::getChildren方法代码示例

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


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

示例1: addGridCell


//.........这里部分代码省略.........
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}
开发者ID:54993306,项目名称:Classes,代码行数:101,代码来源:SignLayer.cpp

示例2: parseControl


//.........这里部分代码省略.........
		const char* plist = item->first_attribute("plist")->value();
		const char* name = item->first_attribute("name")->value();
		Sprite *pSprite = createAnim(tag,name,png,plist,x,y,rotation);
		container->addChild(pSprite);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlControl) == 0){//controlView
		const char* baseboard = item->first_attribute("baseboard")->value();
		const char* joystick = item->first_attribute("joystick")->value();
		CControlView *pControl = createControl(tag,baseboard,joystick,x,y,rotation);
		container->addChild(pControl);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiContainerScroll) == 0){//scrollView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		int direction = atof(item->first_attribute("direction")->value());
		int innerWidth = atoi(item->first_attribute("innerWidth")->value());
		int innerHeight = atoi(item->first_attribute("innerHeight")->value());
		CScrollView *pView = createScrollView(tag, direction, innerWidth, innerHeight, x, y, w, h, rotation);
		container->addChild(pView);
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pView->getContainer(), iitem);
		}

	}else if (strcmp(item->first_attribute("type")->value(), kTuiContainerLayout) == 0){//layout
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		CLayout *pLayout = createLayout(tag, x, y, w, h, rotation);
		container->addChild(pLayout);
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pLayout, iitem);
		}
		Vector<Node*> vet = pLayout->getChildren();
		for (Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner
			pChild->setPosition(pChild->getPosition() + Point(w / 2, h / 2));
		}

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlListView) == 0){//listView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		const char* img = item->first_attribute("image")->value();
		float num = atof(item->first_attribute("num")->value());
		CListView* pList = createListView(tag,img,x,y,w,h,rotation);
		container->addChild(pList);

		for(int i=0; i<num;i++){//add item
			xml_node<char> *iitem = item->first_node( kTuiNodeControl );
			w = atof(iitem->first_attribute("width")->value());
			h = atof(iitem->first_attribute("height")->value());

			CLayout *pLayout = createLayout(i,0,0,w,h,rotation);
			for( xml_node<char> *iiitem = iitem->first_node( kTuiNodeControl );iiitem!=NULL; iiitem = iiitem->next_sibling()){
				parseControl(pLayout,iiitem);
			}
			Vector<Node*> vet = pLayout->getChildren();
			for(Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner
				if(pChild->getTag() > 0)
					pChild->setPosition(pChild->getPosition()+Point(w/2,h/2));
			}
			pList->insertNodeAtLast(pLayout);
		}
		pList->reloadData();

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlPageView) == 0){//pageView
		float w = atof(item->first_attribute("width")->value());
开发者ID:Kudoo,项目名称:Tui-x,代码行数:67,代码来源:TuiManager.cpp


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