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


C++ UILayer::setContentSize方法代码示例

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


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

示例1:

TanSuoLayer::TanSuoLayer()
{
	m_nFontSize = 24;
	m_nMaxCountDestroy = 3;
	m_bIsJieFeng = false;
	m_nSelectProId = -1;
	mBg = BaseSprite::create("xunbao_bg.png");
	addChild(mBg);
	mBg->setPosition(ccp(mWinSize.width/2, mBg->getContentSize().height/2));
	mMainMenu = CCMenu::create();
	mBg->addChild(mMainMenu, 10);
	mMainMenu->setPosition(ccp(0,0));
	CCMenuItemImage *yijian = CCMenuItemImage::create(
		"xunbao_anniu_yijianxunbao.png",
		"xunbao_anniu_yijianxunbao_select.png",
		this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
	mMainMenu->addChild(yijian, 0, Tag_MenuItem_YiJianTanSuo);
	yijian->setPosition(ccp(548,mBg->getContentSize().height-674));

	Button *tansuo = Button::create();
	tansuo->loadTextures("xunbao_anniu_xunbao.png","xunbao_anniu_xunbao_select.png","xunbao_anniu_xunbao_select.png",UI_TEX_TYPE_LOCAL);
	/*CCMenuItemImage *tansuo = CCMenuItemImage::create(
		"xunbao_anniu_xunbao.png",
		"xunbao_anniu_xunbao_select.png",
		this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));*/
	tansuo->addTouchEventListener(this,SEL_TouchEvent(&TanSuoLayer::clickXunBao));

	


	UILayer* layer = UILayer::create();
	layer->ignoreAnchorPointForPosition(false);
	layer->setContentSize(tansuo->getContentSize());
	layer->setAnchorPoint(ccp(0.5,0.5));
	layer->addWidget(tansuo);
	layer->setPosition(320,mBg->getContentSize().height-674);//以前cpp(x,y) 现在左边 都是Point  比如颜色 ccWHITE 也改成了Color3B::WHITE
	mBg->addChild(layer);
	tansuo->setPosition(ccp(tansuo->getContentSize().width / 2 , tansuo->getContentSize().height / 2));

	m_sXunBaoSpr = CCSprite::create("xunbao_anniu_xunbao_xiaoguo.png");
	m_sXunBaoSpr->setPosition(ccp(320,mBg->getContentSize().height-674));
	mBg->addChild(m_sXunBaoSpr);
	m_sXunBaoSpr->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.0f),CCFadeIn::create(1.0f),NULL)));
	//mMainMenu->addChild(tansuo, 0, Tag_MenuItem_TanSuo);
	//tansuo->setPosition(ccp(320,mBg->getContentSize().height-674));
	{
		CCMenuItemImage *jiefen = CCMenuItemImage::create(
			"xunbao_anniu_jiechufengyin.png",
			"xunbao_anniu_jiechufengyin_select.png",
			this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
		mMainMenu->addChild(jiefen, 0, Tag_MenuItem_JieFen);
		jiefen->setPosition(ccp(320,mBg->getContentSize().height-437));
		jiefen->setVisible(false);
		CCSprite *img = CCSprite::create("xunbao_anniu_jiechufengyin_xiaoguo.png");
		jiefen->addChild(img);
		img->setPosition(ccp(jiefen->getContentSize().width/2, jiefen->getContentSize().height/2));
		img->runAction(CCRepeatForever::create(CCSequence::create(
			CCFadeTo::create(1, 50), CCFadeTo::create(1, 255), NULL)));
	}
	mMainMenu->setVisible(false);

	//title
	CCLabelTTF *tilte = CCLabelTTF::create(LFStrings::getValue("XunBaoShuoMing").c_str(), fontStr_kaiti, m_nFontSize);
	mBg->addChild(tilte);
	tilte->setColor(fonColor_PuTong);
	tilte->setPosition(ccp(mBg->getContentSize().width/2, mBg->getContentSize().height-110));
	//2
	CCLabelTTF *la1 = CCLabelTTF::create(LFStrings::getValue("XunBaoJieFeng").c_str(), fontStr_kaiti, m_nFontSize);
	mBg->addChild(la1);
	la1->setAnchorPoint(ccp(0, 0.5));
	la1->setColor(fonColor_CiYao);
	la1->setPosition(ccp(134, mBg->getContentSize().height-140));
	CCLabelTTF *la2 = CCLabelTTF::create((LFStrings::getValue("shenbing")+LFStrings::getValue("zhuangbei")).c_str()
		, fontStr_kaiti, m_nFontSize);
	la1->addChild(la2);
	la2->setColor(ImageManager::getManager()->getShowColor(ZhuangbeiColour_Chuanqi, false, false));
	la2->setPosition(ccp(la1->getContentSize().width+la2->getContentSize().width/2, la1->getContentSize().height/2));
	la1->setPositionX((mBg->getContentSize().width-la1->getContentSize().width-la2->getContentSize().width)/2);

}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:80,代码来源:TanSuoLayer.cpp


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