本文整理汇总了C++中CCMenu::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::retain方法的具体用法?C++ CCMenu::retain怎么用?C++ CCMenu::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::retain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MapControlLayer::init()
{
if ( !CCLayerColor::init() )
{
return false;
}
removeAllChildrenWithCleanup(true);
CCSize screenSize = GameParams::getInstanse()->screenSize;
sizeHeight = 200;
showed = false;
layersCnt_ = 0;
m_bTouchEnabled = true;
CCLabelTTF * mapLabel = CCLabelTTF::create("Карта", "Marker Felt", 22);
mapLabel->setAnchorPoint(ccp(0,1));
mapLabel->setPosition(ccp(25,sizeHeight-5));
CCLabelTTF * layers = CCLabelTTF::create("Слои", "Marker Felt", 18);
layers->setAnchorPoint(ccp(0,1));
layers->setPosition(ccp(25,sizeHeight-35));
CCMenuItemLabel* layersPlus = CCMenuItemLabel::create(CCLabelTTF::create("+", "Marker Felt", 18),this,menu_selector(MapControlLayer::plusLayers));
layersPlus->setAnchorPoint(ccp(0,1));
layersPlus->setPosition(ccp(135,sizeHeight-35));
CCMenuItemLabel* layersMinus = CCMenuItemLabel::create(CCLabelTTF::create("-", "Marker Felt", 18),this,menu_selector(MapControlLayer::minusLayers));
layersMinus->setAnchorPoint(ccp(0,1));
layersMinus->setPosition(ccp(95,sizeHeight-35));
layersCnt = CCLabelTTF::create("1", "Marker Felt", 18);
layersCnt->setAnchorPoint(ccp(0,1));
layersCnt->setPosition(ccp(110,sizeHeight-35));
CCLabelTTF * tileset = CCLabelTTF::create("Тайлсет", "Marker Felt", 18);
tileset->setAnchorPoint(ccp(0,1));
tileset->setPosition(ccp(25,sizeHeight-65));
CCMenuItemLabel* tilesetPlus = CCMenuItemLabel::create(CCLabelTTF::create("+", "Marker Felt", 18),this,menu_selector(MapControlLayer::plusTileset));
tilesetPlus->setAnchorPoint(ccp(0,1));
tilesetPlus->setPosition(ccp(135,sizeHeight-65));
CCMenuItemLabel* tilesetMinus = CCMenuItemLabel::create(CCLabelTTF::create("-", "Marker Felt", 18),this,menu_selector(MapControlLayer::minusTileset));
tilesetMinus->setAnchorPoint(ccp(0,1));
tilesetMinus->setPosition(ccp(95,sizeHeight-65));
tilesetCnt = CCLabelTTF::create("1", "Marker Felt", 18);
tilesetCnt->setAnchorPoint(ccp(0,1));
tilesetCnt->setPosition(ccp(110,sizeHeight-65));
CCMenuItemLabel* SaveMap = CCMenuItemLabel::create(CCLabelTTF::create("Сохранить!", "Marker Felt", 22),this,menu_selector(MapControlLayer::SaveMap));
SaveMap->setColor(ccc3(20, 200, 20));
SaveMap->setAnchorPoint(ccp(0,1));
SaveMap->setPosition(ccp(35,sizeHeight-95));
CCMenuItemLabel* closeMap = CCMenuItemLabel::create(CCLabelTTF::create("Закрыть", "Marker Felt", 22),this,menu_selector(MapControlLayer::CloseMap));
closeMap->setColor(ccc3(20, 20, 200));
closeMap->setAnchorPoint(ccp(0,1));
closeMap->setPosition(ccp(35,sizeHeight-125));
CCMenuItemLabel* deleteMap = CCMenuItemLabel::create(CCLabelTTF::create("Удалить", "Marker Felt", 22),this,menu_selector(MapControlLayer::DeleteMap));
deleteMap->setColor(ccc3(200, 20, 20));
deleteMap->setAnchorPoint(ccp(0,1));
deleteMap->setPosition(ccp(35,sizeHeight-155));
setColor(ccc3(144,144,144));
setOpacity(220);
setContentSize(CCSizeMake(screenSize.width-GameParams::getInstanse()->programLayerWidth,sizeHeight));
arrow = CCMenuItemImage::create("System/down.png", "System/down.png",this, menu_selector(MapControlLayer::showLayer));
CCMenu * menu = CCMenu::create(arrow, SaveMap, closeMap, deleteMap, layersPlus, layersMinus, tilesetPlus, tilesetMinus, NULL);
arrow->setAnchorPoint(ccp(0.5,1));
arrow->setPosition(ccp((screenSize.width-GameParams::getInstanse()->programLayerWidth)/2,0));
menu->setPosition(CCPointZero);
menu->retain();
addChild(menu,2);
addChild(mapLabel,2);
addChild(layers,2);
addChild(tileset,2);
addChild(layersCnt,2);
addChild(tilesetCnt,2);
// robots
robotsPrefs = RobotPrefsScrolLayer::getInstanse();
robotsPrefs->setContentSize(CCSizeMake(screenSize.width-GameParams::getInstanse()->programLayerWidth - 200,sizeHeight));
robotsPrefs->setPosition(ccp(200,0));
robotsPrefs->frame = CCRectMake(200, 0, screenSize.width-GameParams::getInstanse()->programLayerWidth - 200, sizeHeight);
// Robot4Edit * robot4Edit = Robot4Edit::create();
//.........这里部分代码省略.........
示例2: while
ControlLayer::ControlLayer( LayerSwitcher* pLayerSwitcher,MapControl* pControl )
{
m_pLayerSwitcher = pLayerSwitcher;
m_pControl = pControl;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pZoomIn = CCMenuItemImage::create(
"zoomin.png",
"zoomin.png",
this,
menu_selector(ControlLayer::zoomIn));
CC_BREAK_IF(! pZoomIn);
// Place the menu item bottom-right conner.
pZoomIn->setPosition(ccp(25, 25));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pZoomIn, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1,1);
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pZoomOut = CCMenuItemImage::create(
"zoomout.png",
"zoomout.png",
this,
menu_selector(ControlLayer::zoomOut));
CC_BREAK_IF(! pZoomOut);
// Place the menu item bottom-right conner.
pZoomOut->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 25, 25));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu2 = CCMenu::create(pZoomOut, NULL);
pMenu2->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu2);
this->addChild(pMenu2,2,2);
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pLayerSwitch = CCMenuItemImage::create(
"r_overlays.png",
"r_overlays.png",
this,
menu_selector(ControlLayer::layerswitch));
CC_BREAK_IF(! pLayerSwitch);
// Place the menu item bottom-right conner.
pLayerSwitch->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height-25));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu3 = CCMenu::create(pLayerSwitch, NULL);
pMenu3->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu3);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu3, 3,3);
m_ScaleList.reserve(19);
for (int i=0;i<19;++i)
{
CCString str;
str.initWithFormat("scale%d.png",i+1);
CCMenuItemImage *pScaleItem = CCMenuItemImage::create(str.getCString(),str.getCString());
CC_BREAK_IF(! pScaleItem);
// Place the menu item bottom-right conner.
pScaleItem->setPosition(ccp(100, 35));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pScaleMenu = CCMenu::create(pScaleItem, NULL);
pScaleMenu->setPosition(CCPointZero);
pScaleMenu->retain();
m_ScaleList.push_back(pScaleMenu);
}
int zoom = pControl->getZoomLevel();
addChild(m_ScaleList[zoom-1],4,4);
} while (0);
}