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


C++ CCMenuItemImage::retain方法代码示例

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


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

示例1: init

bool HeadUpDisplay::init(){

	if(!CCMenu::init())
		return false;

	/* Adding a "close" button to exit. */
	CCMenuItemImage *pCloseItem = CCMenuItemImage::create("CloseNormal.png",
			"CloseSelected.png", this, menu_selector(HeadUpDisplay::menuCloseCallback));

	CCSize scrSize = CCDirector::sharedDirector()->getWinSize();
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	pCloseItem->setPosition(
					ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
						origin.y + pCloseItem->getContentSize().height/2));
	this->addChild(pCloseItem,1);


	/* Mesh */
	CCSprite* mesh = CCSprite::create();
	mesh->setTextureRect(CCRect(0,0,scrSize.width,scrSize.height));
	mesh->setColor(ccc3(0,0,0));
	mesh->setOpacity(0);
	mesh->setAnchorPoint(ccp(0,0));
	mesh->setPosition(CCPointZero);
	mesh->setTag(_meshTag);
	this->addChild(mesh,0);


	/* Bubble Talk */
	CCSprite* bubble = CCSprite::create("bubbleTalk.png");
	CCPoint bblePos = scrSize/2;
	bubble->setPosition(bblePos);
	bubble->setScale(0);
	bubble->setTag(_bubbleTalkTag);
	this->addChild(bubble,0);


	/* Message */
	CCLabelTTF* labelMsg = CCLabelTTF::create("Bonjour!\n :)","Artial", 32);
	CCSize bubbleSize = bubble->getContentSize();
	labelMsg->setPosition(bubbleSize/2);
	labelMsg->setOpacity(0);
	labelMsg->setTag(_messageTag);
	bubble->addChild(labelMsg,0);


	/* Accept Button */
	CCMenuItemImage* acceptButton = CCMenuItemImage::create(
			"acceptButton.png","acceptButtonPressed.png", this, menu_selector(HeadUpDisplay::hideMessage));
	acceptButton->retain();
	CCSize aBtnSize = acceptButton->getContentSize();
	acceptButton->setPosition(ccp(
			bblePos.x + bubbleSize.width/2  - aBtnSize.width  * .25f,
			bblePos.y - bubbleSize.height/2 + aBtnSize.height * .25f));
	acceptButton->setVisible(false);
	this->addChild(acceptButton,0,_acceptButtonTag);

	this->setPosition(CCPointZero);

	return true;
}
开发者ID:marcochavezf,项目名称:cocos2dx-test,代码行数:62,代码来源:HeadUpDisplay.cpp


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