本文整理汇总了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;
}