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


C++ CCMenuItemLabel::setPosition方法代码示例

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


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

示例1: onEnter

void GUIEditorTestScene::onEnter()
{
    CCScene::onEnter();
    
    CCLabelTTF* label = CCLabelTTF::create("Back", "Arial", 20);
    //#endif
    CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(GUIEditorTestScene::BackCallback));
    
    CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);
    
    pMenu->setPosition( CCPointZero );
    pMenuItem->setPosition( ccp( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );
    
    addChild(pMenu, 1);
}
开发者ID:1901,项目名称:cocos2d-x,代码行数:15,代码来源:GUIEditorTest.cpp

示例2: setupViews

//  对控件以及布景 进行初始化
void OptionLayer::setupViews(){
    
    //  加入背景图片
    
    setBackgroundImage( "loading.png" );
    
    //  加入menutitle
    CCSprite* title = CCSprite::create( "menuTitle.png",CCRectMake(0, 0, 133, 36) );
    
    title->setAnchorPoint( ccp(0.5, 1) );
    title->setPosition( ccp( getWinSize().width / 2 ,getWinSize().height -20 ) );
    this->addChild( title );
    
    //  加入menu-- 既是创建CCMenuItemToggle
    CCMenuItemToggle* music_trigger = CCMenuItemToggle::createWithTarget(this, menu_selector(OptionLayer::music_trigger_callback), CCMenuItemFont::create( "Music : On" ),CCMenuItemFont::create("Music : Off"),NULL);
    
    music_trigger->setPosition( ccp( getWinSize().width / 2 ,getWinSize().height / 2 ) );
    //  根据背景音乐播放与否来显示相关的文字选项
    
    if( SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying() )
    {
              
        music_trigger->setSelectedIndex( 1 );
        
    }
    else
    {
        music_trigger->setSelectedIndex( 0 );
        
    }
    
    //  创建后退的CCMenuItem
    CCLabelBMFont* fontOfBack = CCLabelBMFont::create("Go Back", "arial-14.fnt" );
    
    fontOfBack->setScale(1.5f);
    
    CCMenuItemLabel* backLabel = CCMenuItemLabel::create(fontOfBack, this, menu_selector(OptionLayer::back_callback));
    backLabel->setAnchorPoint( ccp( 0.5, 0 ) );
    backLabel->setPosition( ccp( getWinSize().width / 2, 30) );
    
    
    CCMenu* menu = CCMenu::create( music_trigger,backLabel,NULL);
    
    menu ->setPosition( CCPointZero );
//    menu->setPosition( ccp( getWinSize().width / 2, getWinSize().height /  2) );
    
    this->addChild( menu );
}
开发者ID:897290110,项目名称:MyMoonWarrior,代码行数:49,代码来源:OptionLayer.cpp

示例3: init

bool CGameStart::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(!CCLayer::init());

        CCSize size = CCDirector::sharedDirector()->getWinSize();

        // background
        CCSprite *bg = CCSprite::spriteWithFile("background.png");
        CC_BREAK_IF(!bg);

        bg->setPosition(ccp(size.width/2, size.height/2));
        this->addChild(bg);

        // 'Tank Battle'
        CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Tank Battle", "Arial", 60);
        CC_BREAK_IF(!pLabel);
        pLabel->setColor(ccRED);
        pLabel->setPosition(ccp(size.width/2, size.height/2 + 100));
        this->addChild(pLabel);

        // 'play game'
        pLabel = CCLabelTTF::labelWithString("Play Game", "Arial", 24);
        CC_BREAK_IF(! pLabel);

        CCMenuItemLabel *pPlayItem = CCMenuItemLabel::itemWithLabel(
            pLabel, this,
            menu_selector(CGameStart::menuPlayCallback));

        CC_BREAK_IF(! pPlayItem);

        pPlayItem->setPosition(ccp(size.width/2, size.height/2));

        CCMenu* pMenu = CCMenu::menuWithItems(pPlayItem, NULL);
        pMenu->setPosition(CCPointZero);
        CC_BREAK_IF(! pMenu);

        this->addChild(pMenu, 1);

        bRet = true;
    } while (0);

    return bRet;
}
开发者ID:Javaoom,项目名称:TankBattle,代码行数:46,代码来源:GameStart.cpp

示例4: init

// on "init" you need to initialize your instance
bool VirtualCurrencyLayer::init() {
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() ) {
        return false;
    }

    this->setKeypadEnabled(true);

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    CCLabelTTF* title = CCLabelTTF::create("Virtual Currency", "Arial", 24);
	title->setPosition( ccp(size.width / 2, size.height - 20));
	this->addChild(title, 1);

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "b1.png",
                                        "b2.png",
                                        this,
                                        menu_selector(VirtualCurrencyLayer::menuBackCallback) );
    pCloseItem->setPosition( ccp(pCloseItem->getContentSize().width / 2 , 20) );

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);
    

    float step = 35;
    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        CCLabelTTF* label = CCLabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
        CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(VirtualCurrencyLayer::eventMenuCallback));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = size.height - step*i - 100;
        pMenuItem->setPosition( ccp(size.width / 2, yPos));
    }

    return true;
}
开发者ID:CaiZhongda,项目名称:game-analytics-cocos2dx,代码行数:46,代码来源:VirtualCurrencyScene.cpp

示例5: onEnter

void TestScene::onEnter()
{
    CCScene::onEnter();

    //add the menu item for back to main menu
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//    CCLabelBMFont* label = CCLabelBMFont::create("MainMenu",  "fonts/arial16.fnt");
//#else
    CCLabelTTF* label = CCLabelTTF::create("MainMenu", "Arial", 20);
//#endif
    CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestScene::MainMenuCallback));

    CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);

    pMenu->setPosition( CCPointZero );
    pMenuItem->setPosition( ccp( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );

    addChild(pMenu, 1);
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:19,代码来源:testBasic.cpp

示例6: onEnter

void CustomParticleWidgetScene::onEnter()
{
    CCScene::onEnter();
    
    CCLayer* pLayer = new CustomParticleWidgetLayer();
    addChild(pLayer);
    pLayer->release();
    
    CCLabelTTF* label = CCLabelTTF::create("Exit", "Arial", 20);
    //#endif
    CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(CustomParticleWidgetScene::BackCallback));
    
    CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);
    
    pMenu->setPosition( CCPointZero );
    pMenuItem->setPosition( ccp( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );
    
    addChild(pMenu, 1);
}
开发者ID:cdd990,项目名称:cocos2d-x,代码行数:19,代码来源:CustomParticleWidgetTest.cpp

示例7: onEnter

void GameMenuLayer::onEnter()
{
	CCLayer::onEnter();

	CCSize size = CCDirector::sharedDirector()->getWinSize();

	CCMenu* pMenu = CCMenu::create();

	for (int i = 0; i < GameMenuCount; i++)
	{
		CCLabelBMFont* label = CCLabelBMFont::create(GameMenuNames[i].c_str(), "futura-48.fnt", 48);
		CCMenuItemLabel* menuItem = CCMenuItemLabel::create(label, this, menu_selector(GameMenuLayer::menuCallback));
		pMenu->addChild(menuItem, i+1000);
		menuItem->setPosition(ccp(size.width/2, size.height-(i+1)*200));
	}
	pMenu->setPosition(CCPointZero);
	addChild(pMenu);

}
开发者ID:pigling,项目名称:Breakout_BB10,代码行数:19,代码来源:GameMenuScene.cpp

示例8: onEnter

void TestScene::onEnter()
{
    CCScene::onEnter();

    //add the menu item for back to main menu
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//    CCLabelBMFont* label = CCLabelBMFont::labelWithString("MainMenu",  "fonts/arial16.fnt");
//#else
    CCLabelTTF* label = CCLabelTTF::labelWithString("MainMenu", "Arial", 20);
//#endif
    CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestScene::MainMenuCallback));

    CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL);
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    pMenu->setPosition( CCPointZero );
    pMenuItem->setPosition( CCPointMake( s.width - 50, 25) );

    addChild(pMenu, 1);
}
开发者ID:9re,项目名称:cocos2d-x,代码行数:19,代码来源:testBasic.cpp

示例9: ccp

TestController::TestController()
: m_tBeginPos(CCPointZero)
{
    // add close menu
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
    CCMenu* pMenu =CCMenu::create(pCloseItem, NULL);

    pMenu->setPosition( CCPointZero );
    pCloseItem->setPosition(ccp( VisibleRect::right().x - 30, VisibleRect::top().y - 30));

    // add menu items for tests
    m_pItemMenu = CCMenu::create();
    for (int i = 0; i < TESTS_COUNT; ++i)
    {
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//         CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(),  "fonts/arial16.fnt");
// #else
        CCLabelTTF* label = CCLabelTTF::create(g_aTestNames[i].c_str(), "Arial", 24);
// #endif        
        CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback));

        m_pItemMenu->addChild(pMenuItem, i + 10000);
        pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
    }

    m_pItemMenu->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, (TESTS_COUNT + 1) * (LINE_SPACE)));
    m_pItemMenu->setPosition(s_tCurPos);
    addChild(m_pItemMenu);

    setTouchEnabled(true);

    addChild(pMenu, 1);

#if (MSC_VER < 1800) && defined(DEBUG) && (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
//#define CC_PLATFORM_WINRT_SAVE_SHADERS
#if defined(CC_PLATFORM_WINRT_SAVE_SHADERS)
    ShaderTestDemo::precompileShaders();
    CCPrecompiledShaders::sharedPrecompiledShaders()->savePrecompiledShaders();
#endif
#endif

}
开发者ID:bunny1985,项目名称:DigitAdventures,代码行数:42,代码来源:controller.cpp

示例10: init

bool RPGDialogLayer::init(string titleStr, string menuOKStr, int menuItemOKTag, float width, float height, CCObject* target, SEL_MenuHandler seletor)
{
    if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
    {
        this->initCommons(titleStr);
        
        CCTMXTiledMap *mainBg = (CCTMXTiledMap*)this->getChildByTag(kRPGDialogLayerBg);
        CCMenu *menu = (CCMenu*)mainBg->getChildByTag(kRPGDialogLayerBgMenu);
        
        CCLabelTTF *menuOKLab = CCLabelTTF::create(OzgCCUtility::generalString(CCString::create(menuOKStr)->getCString()).c_str(), "Arial", 20, CCSizeMake(120, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        menuOKLab->setColor(ccc3(160, 160, 160));
        CCMenuItemLabel *menuOK = CCMenuItemLabel::create(menuOKLab, target, seletor);
        menuOK->setTag(menuItemOKTag);
        menuOK->setPosition(ccp(190, 60));
        menu->addChild(menuOK);
        
        return true;
    }
    return false;
}
开发者ID:aboduo,项目名称:OzgGameRPG,代码行数:20,代码来源:RPGDialogLayer.cpp

示例11: init

// Initialize the UI for the main game scene
//
// return - false if there was an error in initializing, true otherwise
bool UILayer::init()
{
    CCLabelTTF*      labelPause;  // the text for pause menu item
    CCMenuItemLabel* itemPause;   // menu item for opening the pause menu
    CCMenu*          menu;        // menu to contain the menu item
    CCSize           size;        // the size of the window

    if(!CCLayer::init())
    {
        return false;
    }

    // get the window size from the director
    size = CCDirector::sharedDirector()->getWinSize();

    // create the pause menu item, and add an outline around it to make it readable
    labelPause = CCLabelTTF::create("Pause", FONT_STYLE, Font_Size_Default);
    labelPause->enableStroke(FONT_STROKE_COLOR, FONT_STROKE_THICK);

    // Set up for single player or not
    if(Is_Single_Player)
    {
        SetUpSinglePlayer(size);
    }
    else
    {
        SetUpMultiPlayer(size);
    }

    itemPause  = CCMenuItemLabel::create(labelPause, this, menu_selector(UILayer::HandlePausePressed));
    itemPause->setColor(MENU_COLOR);
    itemPause->setPosition(ccp(size.width * PAUSE_WIDTH_POS, size.height * PAUSE_HEIGHT_POS));

    // create the menu containing the pause item
    menu = CCMenu::create(itemPause, NULL);
    menu->setPosition(CCPointZero);
    this->addChild(m_scoreLabel, 1);
    this->addChild(menu, 1);

    return true;
}
开发者ID:Rykkata,项目名称:483w,代码行数:44,代码来源:UILayer.cpp

示例12: init

bool IntroScene::init(){
	if (!CCLayer::init()){    //初始化父类
		return false;
	}
	char * pics[6] = { "storylead1.jpg", "storylead2.jpg", "storylead3.jpg", "storylead4.jpg", "storylead5.jpg", "storylead6.jpg" };
	for (int i = 0; i < 6; ++i){
		IntroScene::picSrc[i] = pics[i];
	}
	IntroScene::currPic = 0;
	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
	//获取屏幕大小
	CCSize visibleSize = CCDirector::sharedDirector()->getWinSize();

	IntroScene::IntroBackground1 = CCSprite::create(picSrc[0]);
	CCSize pictureSize1 = IntroScene::IntroBackground1->getContentSize();
	IntroScene::IntroBackground1->setScaleX(visibleSize.width / pictureSize1.width);
	IntroScene::IntroBackground1->setScaleY(visibleSize.height / pictureSize1.height);
	IntroScene::IntroBackground1->setPosition(ccp(visibleSize.width / 2.0f, visibleSize.height / 2.0f));
	this->addChild(IntroScene::IntroBackground1);

	IntroScene::IntroBackground2 = CCSprite::create(picSrc[1]);
	CCSize pictureSize2 = IntroScene::IntroBackground2->getContentSize();
	IntroScene::IntroBackground2->setScaleX(visibleSize.width / pictureSize2.width);
	IntroScene::IntroBackground2->setScaleY(visibleSize.height / pictureSize2.height);
	IntroScene::IntroBackground2->setPosition(ccp(visibleSize.width / 2.0f, visibleSize.height / 2.0f));
	this->addChild(IntroScene::IntroBackground2);
	IntroScene::IntroBackground2->setVisible(false);

	CCLabelTTF * skipLabel = CCLabelTTF::create("skip", "arial", 32);
	skipLabel->setColor(ccc3(0, 0, 0));
	CCMenuItemLabel * skip = CCMenuItemLabel::create(skipLabel, this, menu_selector(IntroScene::introSkipCall));
	skip->setPosition(ccp(visibleSize.width*0.9, visibleSize.height*0.2));
	auto menu = CCMenu::create(skip, NULL);
	menu->setAnchorPoint(CCPointZero);
	menu->setPosition(CCPointZero);
	this->addChild(menu);

	setTouchEnabled(true);
	return true;
}
开发者ID:AllenShieh,项目名称:LegendaryMonsters,代码行数:40,代码来源:IntroScene.cpp

示例13: endScene

void HelloWorld::endScene( EndReason endReason ) {
	if (_gameOver)
		return;

    _gameOver = true;

    CCSize winSize = CCDirector::sharedDirector()->getWinSize();

    /*
    char message[10] = "You Win";
    if ( endReason == KENDREASONLOSE)
        strcpy(message,"You Lose");
    */

    char message[12] = { 0 };
    sprintf(message, "Score: %d", _score);

    CCLabelBMFont * label ;
    label = CCLabelBMFont::create(message, "fonts/Arial.fnt");
    label->setScale(0.1);
    label->setPosition(ccp(winSize.width/2 , winSize.height*0.6));
    this->addChild(label);

    CCLabelBMFont * restartLabel;
    strcpy(message,"Restart");
    restartLabel = CCLabelBMFont::create(message, "fonts/Arial.fnt");
    CCMenuItemLabel *restartItem = CCMenuItemLabel::create(restartLabel, this, menu_selector(HelloWorld::restartTapped) );
    restartItem->setScale(0.1);
    restartItem->setPosition( ccp(winSize.width/2, winSize.height*0.4));

    CCMenu *menu = CCMenu::create(restartItem, NULL);
    menu->setPosition(CCPointZero);
    this->addChild(menu);

    // clear label and menu
    restartItem->runAction(CCScaleTo::create(0.5, 1.0));
    label ->runAction(CCScaleTo::create(0.5, 1.0));
    // Terminate update callback
    this->unscheduleUpdate();
}
开发者ID:chonla4,项目名称:spacegame,代码行数:40,代码来源:HelloWorldScene.cpp

示例14: ccp

TestController::TestController()
: m_tBeginPos(CCPointZero)
{
    // add close menu
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
    CCMenu* pMenu =CCMenu::create(pCloseItem, NULL);

    pMenu->setPosition( CCPointZero );
    pCloseItem->setPosition(ccp( VisibleRect::right().x - 30, VisibleRect::top().y - 30));

    // add menu items for tests
    m_pItemMenu = CCMenu::create();
    for (int i = 0; i < TESTS_COUNT; ++i)
    {
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//         CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(),  "fonts/arial16.fnt");
// #else
        CCLabelTTF* label = CCLabelTTF::create(g_aTestNames[i].c_str(), "Arial", 24);
// #endif        
        CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback));

        m_pItemMenu->addChild(pMenuItem, i + 10000);
        pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
        
        if (!isTestDemoEnabled(i))
        {
            pMenuItem->setColor(ccGRAY);
            pMenuItem->setEnabled(false);
        }
    }

    m_pItemMenu->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, (TESTS_COUNT + 1) * (LINE_SPACE)));
    m_pItemMenu->setPosition(s_tCurPos);
    addChild(m_pItemMenu);

    setTouchEnabled(true);

    addChild(pMenu, 1);

}
开发者ID:aselushat,项目名称:Cocos2d-WindowsPhone,代码行数:40,代码来源:controller.cpp

示例15: init

bool TweetScene::init()
{
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    
    CCSize editBoxSize = CCSizeMake(visibleSize.width/2, 50);
    CCEditBox* editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("9patch.png"));
    editBox->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
    editBox->setFontColor(ccWHITE);
    editBox->setPlaceHolder("TextBox");
    editBox->setReturnType(kKeyboardReturnTypeDone);
    editBox->setTag(1);
    this->addChild(editBox);
    
    CCLabelTTF* tweetLabel = CCLabelTTF::create("つぶやく", "arial", 48);
    CCMenuItemLabel* tweetItem = CCMenuItemLabel::create(tweetLabel, this, menu_selector(TweetScene::tweet));
    tweetItem->setPosition(ccp(visibleSize.width/2,visibleSize.height-tweetLabel->getContentSize().height));
    
    CCMenu* tweetMenu = CCMenu::create(tweetItem,NULL);
    tweetMenu->setPosition(CCPointZero);
    this->addChild(tweetMenu);
    return true;
}
开发者ID:Nush,项目名称:cocos2dx_study,代码行数:22,代码来源:TweetScene.cpp


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