本文整理汇总了C++中CCMenuItemToggle::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemToggle::getContentSize方法的具体用法?C++ CCMenuItemToggle::getContentSize怎么用?C++ CCMenuItemToggle::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemToggle
的用法示例。
在下文中一共展示了CCMenuItemToggle::getContentSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMenu
void ConfigMenu::makeMenu(){
CCMenuItemFont::setFontSize(50);
CCMenuItemFont::setFontName("Arial");
//CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback),
//CCMenuItemFont::create("Music OFF"),
//CCMenuItemFont::create("Music ON"), NULL);
CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback),
CCMenuItemLabel::create(CCLabelBMFont::create("Music OFF", "arial-unicode-26.fnt", 300)),
CCMenuItemLabel::create(CCLabelBMFont::create("Music ON", "arial-unicode-26.fnt", 300)), NULL);
CCLabelBMFont* txtShare = CCLabelBMFont::create("Share", "arial-unicode-26.fnt", 300);
//CCMenuItemFont* share = CCMenuItemFont::create("Share", this, menu_selector(ConfigMenu::shareMenuCallback));
//CCLabelTTF* d = CCLabelTTF::create("Share", "Arial", 30);
CCMenuItemLabel* share = CCMenuItemLabel::create(txtShare, this, menu_selector(ConfigMenu::shareMenuCallback));
music->setPosition(ccp(0,-60));
share->setPosition(ccp(0, music->getContentSize().height+music->getPositionY()+20));
share->setScale(2);
music->setScale(2);
CCMenu *menu = CCMenu::create(music, share, NULL);
//menu->setPosition(ccp(400,0));
menu->setOpacity(kCCMenuHandlerPriority);
this->addChild(menu);
if(!CCUserDefault::sharedUserDefault()->getBoolForKey(CONFIG_KEY_HAS_MUSIC)){
music->setSelectedIndex(1);
}else{
music->setSelectedIndex(0);
}
}
示例2: initMenuToggle
void IOSStoreLayer::initMenuToggle()
{
//开宝箱按钮开关
CCMenuItemSprite* pNorItem = CCMenuItemSprite::create(
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_kaibaoxiang.png").c_str()),
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_kaibaoxiang.png").c_str()));
CCMenuItemSprite* pPreItem = CCMenuItemSprite::create(
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_kaibaoxiang_select.png").c_str()),
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_kaibaoxiang_select.png").c_str()));
CCMenuItemToggle* pToggle = CCMenuItemToggle::createWithTarget(this,
menu_selector(IOSStoreLayer::clickToggleCallBack),
pNorItem,
pPreItem, NULL);
pToggle->setTag(kaibaoxiang_toggle_tag);
pToggle->setPosition(ccp(m_pBg->getContentSize().width/2 - pToggle->getContentSize().width/2,
m_pBg->getContentSize().height/2 + pToggle->getContentSize().width/2 +25));
pToggle->setSelectedIndex(1);
m_pBgMenu->addChild(pToggle);
//购买星星按钮开关
pNorItem = CCMenuItemSprite::create(
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_goumaixingxing.png").c_str()),
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_goumaixingxing.png").c_str()));
pPreItem = CCMenuItemSprite::create(
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_goumaixingxing_select.png").c_str()),
CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_goumaixingxing_select.png").c_str()));
pToggle = CCMenuItemToggle::createWithTarget(this,
menu_selector(IOSStoreLayer::clickToggleCallBack),
pNorItem,
pPreItem, NULL);
pToggle->setTag(buystar_toggle_tag);
pToggle->setPosition(ccp(m_pBg->getContentSize().width/2 + pToggle->getContentSize().width/2,
m_pBg->getContentSize().height/2 + pToggle->getContentSize().width/2 + 25));
m_pBgMenu->addChild(pToggle);
}
示例3:
bool Recipe15::init()
{
if ( !CCLayerGradient::initWithColor(ccc4(170,145,25,255),ccc4(17,220,160,255),ccp(0.0f,1.0f)))
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
m_points = 0;
m_actionType = 1;
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
CCSprite *player = CCSprite::create("monkey01.png");
player->setTag(1);
player->setPosition(ccp(player->getContentSize().height*3/2, visibleSize.width/2));
player->setOpacity(210);
this->addChild(player);
this->schedule(schedule_selector(Recipe15::gameLogic),3.0);
this->scheduleUpdate();
CCMenuItemImage* pCloseItem = CCMenuItemImage::create(
"button_close.png",
"button_close_pressed.png",
this,
menu_selector(Recipe15::menuCloseCallback));
pCloseItem->setPosition(ccp(
visibleSize.width - pCloseItem->getContentSize().width/2,
pCloseItem->getContentSize().height/2));
//CCMenu* pMenu = CCMenu::create(pCloseItem,NULL);
//pMenu->setPosition(CCPointZero);
// this->addChild(pMenu);
CCSprite* item1 = CCSprite::create("button_close.png");
CCSprite* item2 = CCSprite::create("button_close.png");
item2->setColor(ccc3(102,102,255));
CCMenuItemSprite* pCloseItem2 =
CCMenuItemSprite::create(item1,item2,this,
menu_selector(Recipe15::menuCloseCallback));
pCloseItem2->setPosition(ccp(
visibleSize.width -pCloseItem->getContentSize().width*3/2,
pCloseItem->getContentSize().height/2));
CCMenu* pMenu2 = CCMenu::create(pCloseItem,pCloseItem2,NULL);
pMenu2->setPosition(CCPointZero);
this->addChild(pMenu2);
CCMenuItemImage* menuItemOff = CCMenuItemImage::create(
"button_check_off.png",
"button_check_off_pressed.png",NULL);
CCMenuItemImage* menuItemOn = CCMenuItemImage::create(
"button_check_on.png",
"button_check_on_pressed.png",NULL);
CCMenuItemToggle* toggleItem =
CCMenuItemToggle::createWithTarget(this,menu_selector(Recipe15::changeMode),menuItemOff,menuItemOn,NULL);
toggleItem->setPosition(ccp(
toggleItem->getContentSize().width/2,
visibleSize.height - toggleItem->getContentSize().height/2));
CCMenu* toggleMenu = CCMenu::create(toggleItem,NULL);
toggleMenu->setPosition(0,0);
toggleMenu->setTag(3);
this->addChild(toggleMenu);
CCLabelTTF *scoreLabel = CCLabelTTF::create("SCORE","aria",48);
scoreLabel->setPosition(ccp(visibleSize.width/2,visibleSize.height - scoreLabel->getContentSize().height/2));
scoreLabel->setTag(10);
this->addChild(scoreLabel);
CCLabelTTF* pointsLabel = CCLabelTTF::create("0","arial",48);
pointsLabel->setPosition(ccp(scoreLabel->getPositionX() + scoreLabel->getContentSize().width,
visibleSize.height - pointsLabel->getContentSize().height/2));
pointsLabel->setTag(11);
this->addChild(pointsLabel);
return true;
}