本文整理汇总了C++中CCMenu::alignItemsVertically方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::alignItemsVertically方法的具体用法?C++ CCMenu::alignItemsVertically怎么用?C++ CCMenu::alignItemsVertically使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::alignItemsVertically方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool HelloWorldScene::init(void)
{
CCScene::init();
CCLabelTTF* label = CCLabelTTF::labelWithString("CCCrypto", "Arial", 24);
CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(HelloWorldScene::testCCCrypto));
label = CCLabelTTF::labelWithString("CCNative", "Arial", 24);
CCMenuItemLabel* item2 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(HelloWorldScene::testCCNative));
label = CCLabelTTF::labelWithString("CCNetwork", "Arial", 24);
CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(HelloWorldScene::testCCNetwork));
label = CCLabelTTF::labelWithString("CCStore", "Arial", 24);
CCMenuItemLabel* item4 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(HelloWorldScene::testCCStore));
label = CCLabelTTF::labelWithString("CCOpenFeint", "Arial", 24);
CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(HelloWorldScene::testCCOpenFeint));
CCMenu* pMenu = CCMenu::menuWithItems(item1, item2, item3, item4, item5, NULL);
pMenu->alignItemsVertically();
addChild(pMenu);
return true;
}
示例2: init
bool CCCryptoScene::init(void)
{
CCScene::init();
CCLabelTTF* label = CCLabelTTF::labelWithString("encryptAES256() / decryptAES256()", "Arial", 22);
CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(CCCryptoScene::testEncryptAES256));
label = CCLabelTTF::labelWithString("encodeBase64() / decodeBase64()", "Arial", 22);
CCMenuItemLabel* item2 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(CCCryptoScene::testEncodeBase64));
label = CCLabelTTF::labelWithString("MD5()", "Arial", 22);
CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(CCCryptoScene::testMD5));
label = CCLabelTTF::labelWithString("- BACK -", "Arial", 22);
CCMenuItemLabel* itemBack = CCMenuItemLabel::itemWithLabel(label,
this,
menu_selector(CCCryptoScene::backToMainScene));
CCMenu* pMenu = CCMenu::menuWithItems(item1, item2, item3, itemBack, NULL);
pMenu->alignItemsVertically();
addChild(pMenu);
return true;
}
示例3:
/**
* Impelmentation of RenderTextureSave
*/
RenderTextureSave::RenderTextureSave()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
// create a render texture, this is what we are going to draw into
m_pTarget = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height);
m_pTarget->retain();
m_pTarget->setPosition(ccp(s.width / 2, s.height / 2));
// note that the render texture is a CCNode, and contains a sprite of its texture for convience,
// so we can just parent it to the scene like any other CCNode
this->addChild(m_pTarget, -1);
// create a brush image to draw into the texture with
m_pBrush = CCSprite::spriteWithFile("Images/fire.png");
m_pBrush->retain();
m_pBrush->setOpacity(20);
this->setIsTouchEnabled(true);
// Save Image menu
CCMenuItemFont::setFontSize(16);
CCMenuItem *item1 = CCMenuItemFont::itemFromString("Save Image", this, menu_selector(RenderTextureSave::saveImage));
CCMenuItem *item2 = CCMenuItemFont::itemFromString("Clear", this, menu_selector(RenderTextureSave::clearImage));
CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL);
this->addChild(menu);
menu->alignItemsVertically();
menu->setPosition(ccp(s.width - 80, s.height - 30));
}
示例4: getChildByTag
void Bug422Layer::reset()
{
static int localtag = 0;
localtag++;
// TO TRIGGER THE BUG:
// remove the itself from parent from an action
// The menu will be removed, but the instance will be alive
// and then a new node will be allocated occupying the memory.
// => CRASH BOOM BANG
CCNode *node = getChildByTag(localtag-1);
CCLog("Menu: %p", node);
removeChild(node, false);
// [self removeChildByTag:localtag-1 cleanup:NO];
CCMenuItem *item1 = CCMenuItemFont::itemFromString("One", this, menu_selector(Bug422Layer::menuCallback));
CCLog("MenuItemFont: %p", item1);
CCMenuItem *item2 = CCMenuItemFont::itemFromString("Two", this, menu_selector(Bug422Layer::menuCallback));
CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL);
menu->alignItemsVertically();
float x = CCRANDOM_0_1() * 50;
float y = CCRANDOM_0_1() * 50;
menu->setPosition(ccpAdd( menu->getPosition(), ccp(x,y)));
addChild(menu, 0, localtag);
//[self check:self];
}
示例5: init
bool Campaign::init()
{
if ( !SelectSave::init() )
{
return false;
}
stageNum = stageTag0;
SelectStage *stages = SelectStage::create();
addChild(stages);
stages->setTag(campTag_SelectStage);
CCMenuItemFont *start = CCMenuItemFont::create("START",this,menu_selector(Campaign::menuCloseCallback));
CCMenuItemFont *soldiers = CCMenuItemFont::create("SOLDIERS",this,menu_selector(Campaign::menuCloseCallback));
CCMenuItemFont *mainMenu = CCMenuItemFont::create("mainMenu",this,menu_selector(Campaign::menuCloseCallback));
start->setTag(campTag_start);
soldiers->setTag(campTag_soldiers);
mainMenu->setTag(campTag_mainMenu);
CCMenu *menu = CCMenu::create(start,soldiers,mainMenu,NULL);
addChild(menu,10);
menu->setPosition(CCPointZero);
menu->alignItemsVertically();
CCSize size = menu->getContentSize();
CCLOG("%f %f",size.width,size.height);
menu->setPosition(ccp(size.width/6, size.height/6));
// menu->setScale(0.5f);
return true;
}
示例6: onEnter
//------------------------------------------------------------------
//
// RenderTextureSave
//
//------------------------------------------------------------------
KDvoid RenderTextureSave::onEnter ( KDvoid )
{
TestRenderTexture::onEnter ( );
const CCSize& tLyrSize = this->getContentSize ( );
// create a render texture, this is what we're going to draw into
m_pTarget = CCRenderTexture::create ( (KDint) tLyrSize.cx, (KDint) tLyrSize.cy );
m_pTarget->retain ( );
m_pTarget->setPosition ( ccpMid ( tLyrSize ) );
// note that the render texture is a cocosnode, and contains a sprite of it's texture for convience,
// so we can just parent it to the scene like any other cocos node
this->addChild ( m_pTarget, -1 );
// create a brush image to draw into the texture with
m_pBrush = CCSprite::create ( "Images/fire.png" );
m_pBrush->retain ( );
m_pBrush->setColor ( ccRED );
m_pBrush->setOpacity ( 20 );
this->setTouchEnabled ( KD_TRUE );
// Save Image menu
CCMenuItemFont::setFontName ( "fonts/Marker Felt.ttf" );
CCMenuItemFont::setFontSize ( 24 );
CCMenuItem* pItem1 = CCMenuItemFont::create ( "Save Image", this, menu_selector ( RenderTextureSave::saveImage ) );
CCMenuItem* pItem2 = CCMenuItemFont::create ( "Clear" , this, menu_selector ( RenderTextureSave::clearImage ) );
CCMenu* pMenu = CCMenu::create ( pItem1, pItem2, KD_NULL );
this->addChild ( pMenu );
pMenu->alignItemsVertically ( );
pMenu->setPosition ( ccp ( tLyrSize.cx - 80, tLyrSize.cy / 2 ) );
}
示例7: CCPointMake
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
CCSprite *back = CCSprite::spriteWithFile(s_back3);
addChild( back, -10);
back->setAnchorPoint( CCPointMake(0,0) );
CCSize backSize = back->getContentSize();
CCMenuItem *item = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect);
CCMenu *menu = CCMenu::menuWithItems(item, NULL);
menu->alignItemsVertically();
menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
back->addChild(menu);
CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
CCAction* fe = CCRepeatForever::actionWithAction( rot);
item->runAction( fe );
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
CCActionInterval* move_back = move->reverse();
CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
back->runAction(fe2);
}
示例8: onEnter
void SoundPlayWAV::onEnter()
{
SoundDemo::onEnter();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCLabelTTF* label1 = CCLabelTTF::create("Play", "Helvetica", 24);
CCMenuItemLabel* item1 = CCMenuItemLabel::create(label1, this, menu_selector(SoundPlayWAV::onPlayClicked));
CCLabelTTF* label2 = CCLabelTTF::create("Stop", "Helvetica", 24);
CCMenuItemLabel* item2 = CCMenuItemLabel::create(label2, this, menu_selector(SoundPlayWAV::onStopClicked));
CCLabelTTF* label3 = CCLabelTTF::create("Effect(mono)", "Helvetica", 24);
CCMenuItemLabel* item3 = CCMenuItemLabel::create(label3, this, menu_selector(SoundPlayWAV::onEffectMonoClicked));
CCLabelTTF* label4 = CCLabelTTF::create("Effect(stereo)", "Helvetica", 24);
CCMenuItemLabel* item4 = CCMenuItemLabel::create(label4, this, menu_selector(SoundPlayWAV::onEffectStereoClicked));
CCLabelTTF* label5 = CCLabelTTF::create("Volume Down", "Helvetica", 24);
CCMenuItemLabel* item5 = CCMenuItemLabel::create(label5, this, menu_selector(SoundPlayWAV::onVolumeDownClicked));
CCLabelTTF* label6 = CCLabelTTF::create("Volume Up", "Helvetica", 24);
CCMenuItemLabel* item6 = CCMenuItemLabel::create(label6, this, menu_selector(SoundPlayWAV::onVolumeUpClicked));
CCMenu* menu = CCMenu::create(item1, item2, item3, item4, item5, item6, NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
addChild(menu);
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("Audios/bg_wav_mono_16.wav");
SimpleAudioEngine::sharedEngine()->preloadEffect("Audios/effect_wav_mono_16.wav");
SimpleAudioEngine::sharedEngine()->preloadEffect("Audios/effect_wav_stereo_16.wav");
}
示例9: initTipLayer
bool TipLayer::initTipLayer()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *maskLayer = CCLayerColor::node();
maskLayer->initWithColorWidthHeight(ccc4f(0x00,0x00,0x00,0x80),335,350);
//maskLayer->setOpacity(200);
maskLayer->setAnchorPoint(ccp(0.5, 0.5));
maskLayer->setPosition(ccp(winSize.width/2-maskLayer->getContentSize().width/2, winSize.height/2-maskLayer->getContentSize().height/2));
this->addChild(maskLayer);
/*CCSprite *bgSprite = CCSprite::spriteWithFile("actor_pause_bg.png");
this->addChild(bgSprite);
bgSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2));*/
std::string stdNameOne = "";
std::string stdNameTwo = "";
std::string contentImageName = "";
stdNameOne = s_touchfile + s_language + "actor_btn_cancel.png";
stdNameTwo = s_touchfile + s_language + "actor_btn_confirm.png";
contentImageName = s_language + "actor_img_tipContent.png";
//content
CCSprite *pContentSprite = CCSprite::spriteWithFile(contentImageName.c_str());
this->addChild(pContentSprite);
pContentSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2 +100));
CCMenuItemImage *cancelItem = CCMenuItemImage::itemFromNormalImage(stdNameOne.c_str(), stdNameOne.c_str(), this, menu_selector(TipLayer::cancel));
CCMenuItemImage *confirmItem = CCMenuItemImage::itemFromNormalImage(stdNameTwo.c_str(), stdNameTwo.c_str(), this, menu_selector(TipLayer::confirm));
CCMenu *menu = CCMenu::menuWithItems(confirmItem,cancelItem,NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 50));
this->addChild(menu);
CCLayer::setIsKeypadEnabled(true);
return true;
}
示例10: init
bool GameOverScene::init()
{
bool bRet = false;
do
{
CCDirector * pDirector;
CC_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) );
this->setContentSize(pDirector->getWinSize());
CCSprite* bg = CCSprite::create("gameover.png");
bg->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.5));
this->addChild(bg);
CCMenuItemFont* mainMenu = CCMenuItemFont::create("Back To Menu",
this,menu_selector(GameScene::menuPopSceneCallback));
CCMenuItemFont* close = CCMenuItemFont::create("Exit Game",
this,menu_selector(GameOverScene::menuCloseCallback));
CCMenu* menu = CCMenu::create(mainMenu,close,NULL);
menu->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.3));
menu->alignItemsVertically();
this->addChild(menu,1);
// success
bRet = true;
} while (0);
return bRet;
}
示例11: init
bool GameOverLayer::init()
{
do
{
CC_BREAK_IF(!CCLayer::init());
CCLayerColor* backgroundLayer = CCLayerColor::create(
ccc4(255, 255, 255, 128));
addChild(backgroundLayer);
CCSize screenSize = CocosUtils::getScreenSize();
CCMenuItemFont* nextLevel = CCMenuItemFont::create("Next", this,
menu_selector(GameOverLayer::menuCallback));
nextLevel->setTag(MENU_ITEM_NEXT_LEVEL);
nextLevel->setFontName("Consola");
nextLevel->setFontSize(36);
CCMenuItemFont* replay = CCMenuItemFont::create("Replay", this,
menu_selector(GameOverLayer::menuCallback));
replay->setTag(MENU_ITEM_REPLAY);
replay->setFontName("Consola");
replay->setFontSize(36);
CCMenu* menu = CCMenu::create(nextLevel, replay, NULL);
menu->alignItemsVertically();
menu->setPosition(screenSize.width/2, screenSize.height/2);
addChild(menu);
return true;
} while (false);
return false;
}
示例12: pushScene
bool SceneTestLayer3::init()
{
if (CCLayerColor::initWithColor(ccc4(0,0,255,255)))
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCMenuItemFont *item0 = CCMenuItemFont::create("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked));
CCMenuItemFont *item1 = CCMenuItemFont::create("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked));
CCMenuItemFont *item2 = CCMenuItemFont::create("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked));
CCMenuItemFont *item3 = CCMenuItemFont::create("Touch to popToSceneStackLevel(2)", this, menu_selector(SceneTestLayer3::item3Clicked));
CCMenu *menu = CCMenu::create(item0, item1, item2, item3, NULL);
this->addChild(menu);
menu->alignItemsVertically();
this->schedule(schedule_selector(SceneTestLayer3::testDealloc));
CCSprite* sprite = CCSprite::create(s_pPathGrossini);
addChild(sprite);
sprite->setPosition( ccp(s.width/2, 40) );
CCActionInterval* rotate = CCRotateBy::create(2, 360);
CCAction* repeat = CCRepeatForever::create(rotate);
sprite->runAction(repeat);
return true;
}
return false;
}
示例13: init
bool CMenuLayer::init(){
CCLabelTTF* pLabel = CCLabelTTF::create("CraftHero", "Arial", 30);
CCSize size = CCDirector::sharedDirector()->getWinSize();
pLabel->setPosition(ccp(size.width / 2, size.height - 50));
this->addChild(pLabel, 1);
CCSprite* pSprite = CCSprite::create("background.png");
pSprite->setPosition(ccp(size.width/2, size.height/2));
this->addChild(pSprite, 0);
CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(25);
CCMenuItemFont *newGame = CCMenuItemFont::itemWithString("New Game", this,menu_selector(CMenuLayer::gameNew) );
CCMenuItemFont *loading = CCMenuItemFont::itemWithString("Loading", this,menu_selector(CMenuLayer::gameLoad) );
CCMenuItemFont *option = CCMenuItemFont::itemWithString("Option", this,menu_selector(CMenuLayer::gameSetting) );
CCMenuItemFont *quit = CCMenuItemFont::itemWithString("Quit", this,menu_selector(CMenuLayer::gameQuit) );
CCMenu *menu = CCMenu::menuWithItems(newGame,loading,option,quit,NULL);
menu->alignItemsVertically();
this->addChild(menu, 1, 2);
return true;
}
示例14: ccp
KDbool Ch3_SavingSimpleData::init ( KDvoid )
{
if ( !Recipe::init ( ) )
{
return KD_FALSE;
}
// Set font size
CCMenuItemFont::setFontSize ( 30 );
// Add main label
CCLabelBMFont* pChooseDifficultyLabel = CCLabelBMFont::create ( "CHOOSE DIFFICULTY:", "eurostile_30.fnt" );
pChooseDifficultyLabel->setPosition ( ccp ( 240, 250 ) );
pChooseDifficultyLabel->setScale ( 0.5f );
this->addChild ( pChooseDifficultyLabel, 1 );
// Add difficulty choices
m_pEasyMIF = CCMenuItemFont::create ( "Easy" , this, menu_selector ( Ch3_SavingSimpleData::chooseEasy ) );
m_pMediumMIF = CCMenuItemFont::create ( "Medium", this, menu_selector ( Ch3_SavingSimpleData::chooseMedium ) );
m_pHardMIF = CCMenuItemFont::create ( "Hard" , this, menu_selector ( Ch3_SavingSimpleData::chooseHard ) );
m_pInsaneMIF = CCMenuItemFont::create ( "Insane", this, menu_selector ( Ch3_SavingSimpleData::chooseInsane ) );
CCMenu* pMainMenu = CCMenu::create ( m_pEasyMIF, m_pMediumMIF, m_pHardMIF, m_pInsaneMIF, KD_NULL );
pMainMenu->alignItemsVertically ( );
pMainMenu->setPosition ( ccp ( 240, 140 ) );
this->addChild ( pMainMenu, 1 );
// Load any previously chosen difficulty
this->loadDifficulty ( );
return KD_TRUE;
}
示例15: init
bool ConnectionOverlay::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)));
CCMenuItemSprite* qItem = createMenuItemSprite((char*)"btnArrow_Back128x128.png", menu_selector(ConnectionOverlay::onClose));
CCMenu* menu = CCMenu::create(qItem, NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(200,270));
// add this to the layer
this->addChild( menu, 1 );
CCLabelTTF* message = CCLabelTTF::create("Finding an open game...", "Arial", 24);
message->setPosition(ccp(400,100));
this->addChild(message);
bRet = true;
} while (0);
return bRet;
}