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


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

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


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

示例1: showPauseMenu

void BScene::showPauseMenu()
{
    //pause game and input
    Director::getInstance()->pause();
    playerLayer->stopMovement();
    keyHandler->disableByReceiver(playerLayer);
    
    Size windowSize = Director::getInstance()->getWinSize();
    
    overlay = new OverLayer();
    
    //create menu
    Menu* pMenu = Menu::create();
    
    //create menu items
    const Point origin = Director::getInstance()->getVisibleOrigin();
    
    MenuItemLabel* title;
    MenuItemLabel* exitGame;
    MenuItemLabel* levelSelect;
    MenuItemLabel* resume;
    
    //set up Main menu item
    resume = MenuItemLabel::create(LabelTTF::create("Resume", "Arial", 20),
                                   BScene::resumeCB);
    resume->setPosition(0,0);
    pMenu->addChild(resume);
    
    //set up Snake Mode item
    levelSelect = MenuItemLabel::create(LabelTTF::create("Level Select", "Arial", 20),
                                        BScene::levelSelectCB);
    levelSelect->setPosition(0, resume->getPosition().y + resume->getContentSize().height+10);
    pMenu->addChild(levelSelect);
    
    //set up Standard Mode item
    exitGame = MenuItemLabel::create(LabelTTF::create("Exit Game", "Arial", 20),
                                     BScene::exitGameCB);
    exitGame->setPosition(0, levelSelect->getPosition().y + levelSelect->getContentSize().height+10);
    pMenu->addChild(exitGame);
    
    //set up Title item
    title = MenuItemLabel::create(LabelTTF::create("Pause Menu", "Arial", 30));
    title->setPosition(0, exitGame->getPosition().y + exitGame->getContentSize().height+20);
    pMenu->addChild(title);
    
    //center the menu
    float heightofitems = exitGame->getBoundingBox().getMaxY() - resume->getBoundingBox().getMinY();
    pMenu->setPosition(origin.x + windowSize.width/2,
                       origin.y + windowSize.height/2 - heightofitems/2);
    
    overlay->initWithColorMenu( Color4B(0,0,0,150), pMenu);
    addChild(overlay,4);
    layerFocus = 1;
    
    overlay->release();
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:56,代码来源:Bound.cpp

示例2: CreateMenu

void ShowHeroScene::CreateMenu()
{
	auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/menu.xml"); 
	std::string strBeginGame  = strings["BeginGame"].asString(); 
	std::string strCreateGame = strings["CreateGame"].asString(); 
	std::string strJoinGame = strings["JoinGame"].asString(); 
	std::string strExitGame = strings["ExitGame"].asString();  

	if (/*GameLogic::GetInstance()->IsSingleGame()*/GameLogic::GetInstance()->GetGameType() == SINGLE_GAME_TYPE)
	{
		MenuItemLabel* beginGameItem = MenuItemLabel::create(LabelTTF::create(strBeginGame, "Arial", 40), 
			[&](Ref* sender)
		{
			BeginGame();
		}
		);
		beginGameItem->setPosition(Point(500,100));
		auto menu = Menu::create(beginGameItem,NULL);
		menu->setPosition(Point(0, 0));
		addChild(menu);
	}
	else
	{
		if (/*GameLogic::GetInstance()->IsCreator()*/GameLogic::GetInstance()->GetGameType() == CREATE_GAME_TYPE)
		{
			MenuItemLabel* createGameItem = MenuItemLabel::create(LabelTTF::create(strCreateGame, "Arial", 40), 
				[&](Ref* sender)
			{
				CreateGame();
			}
			);
			createGameItem->setPosition(Point(500,100));
			auto menu = Menu::create(createGameItem,NULL);
			menu->setPosition(Point(0, 0));
			addChild(menu);
		}
		else
		{
			MenuItemLabel* joinGameItem = MenuItemLabel::create(LabelTTF::create(strJoinGame, "Arial", 40), 
				[&](Ref* sender)
			{
				JoinGame();
			}
			);
			joinGameItem->setPosition(Point(500,100));
			auto menu = Menu::create(joinGameItem,NULL);
			menu->setPosition(Point(0, 0));
			addChild(menu);
		}
	}
}
开发者ID:mobinsheng,项目名称:Fighting,代码行数:51,代码来源:ShowHeroScene.cpp

示例3: beginPos

BLevelMenu::BLevelMenu(std::function<void(Object*)> cb, LD levels[], int ldCount)
: beginPos(Point::ZERO), callback(cb), levelCount(ldCount)
{
    levelData = levels;
    std::cout<<levels[0].level_name<<std::endl;
    Size visSize = Director::getInstance()->getVisibleSize();
    Point visOrigin = Director::getInstance()->getVisibleOrigin();
    visRect = Rect(visOrigin.x, visOrigin.y, visSize.width, visSize.height);
    
    // add menu items for levels
    itemMenu = Menu::create();
    for (int i = 0; i < levelCount; ++i)
    {
        LabelTTF* label = LabelTTF::create( levelData[i].level_name.c_str(), "Arial", 24);
        MenuItemLabel* menuItem = MenuItemLabel::create(label, cb);
        
        itemMenu->addChild(menuItem, i + 10000);
        menuItem->setPosition( Point( visRect.getMidX(), (visRect.getMaxY() - (i + 1) * LINE_SPACE) ));
    }
    
    itemMenu->setContentSize(Size(visRect.size.width, (levelCount + 1) * (LINE_SPACE)));
    itemMenu->setPosition(s_tCurPos);
    addChild(itemMenu);
    
    setTouchEnabled(true);
    
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:27,代码来源:BoundLevelMenu.cpp

示例4: addChild

void TestArmatureNesting2::onEnter()
{
    ArmatureTestLayer::onEnter();

    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesEnded = CC_CALLBACK_2(TestArmatureNesting2::onTouchesEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

    touchedMenu = false;

    auto label = Label::createWithTTF("Change Mount", "fonts/arial.ttf", 20);
    MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::changeMountCallback, this));

    Menu* pMenu =Menu::create(pMenuItem, nullptr);

    pMenu->setPosition( Vec2() );
    pMenuItem->setPosition(VisibleRect::right().x - 67, VisibleRect::bottom().y + 50);

    addChild(pMenu, 2);

    //Create a hero
    hero = Hero::create("hero");
    hero->setLayer(this);
    hero->playWithIndex(0);
    hero->setPosition(VisibleRect::left().x + 20, VisibleRect::left().y);
    addChild(hero);

    //Create 3 mount
    horse = createMount("horse", VisibleRect::center());

    horse2 = createMount("horse", Vec2(120, 200));
    horse2->setOpacity(200);

    bear = createMount("bear", Vec2(300,70));
}
开发者ID:songmiao,项目名称:WagonWar,代码行数:35,代码来源:ArmatureScene.cpp

示例5: ccp

TestController::TestController()
: _beginPos(PointZero)
{
    // add close menu
    MenuItemImage *pCloseItem = MenuItemImage::create(s_pPathClose, s_pPathClose, CC_CALLBACK_1(TestController::closeCallback, this) );
    Menu* pMenu =Menu::create(pCloseItem, NULL);

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

    // add menu items for tests
    _itemMenu = Menu::create();
    for (int i = 0; i < g_testCount; ++i)
    {
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//         LabelBMFont* label = LabelBMFont::create(g_aTestNames[i].c_str(),  "fonts/arial16.fnt");
// #else
        LabelTTF* label = LabelTTF::create( g_aTestNames[i].test_name, "Arial", 24);
// #endif        
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this));

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

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

    setTouchEnabled(true);

    addChild(pMenu, 1);

}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:34,代码来源:controller.cpp

示例6: showRestartMenu

void HelloWorld::showRestartMenu()
{
    Size winSize = Director::getInstance()->getWinSize();

    const char *message;
    if (_won)
    {
        message = "You win!";
    }
    else
    {
        message = "You lose!";
    }

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

    LabelBMFont *restartLabel = LabelBMFont::create("Restart", "Arial.fnt");
    MenuItemLabel *restartItem = MenuItemLabel::create(restartLabel, [](Object *sender){
        Director::getInstance()->replaceScene(TransitionZoomFlipX::create(0.5f, HelloWorld::createScene()));
    });
    restartItem->setScale(0.1f);
    restartItem->setPosition(winSize.width / 2, winSize.height * 0.4f);

    Menu *menu = Menu::createWithItem(restartItem);
    menu->setPosition(Point::ZERO);
    this->addChild(menu);

    restartItem->runAction(ScaleTo::create(0.5f, 1.0f));
    label->runAction(ScaleTo::create(0.5f, 1.0f));
}
开发者ID:Kurukshetran,项目名称:Cocos2dxGame,代码行数:33,代码来源:HelloWorldScene.cpp

示例7: aboutGameCallback

void HelloWorld::aboutGameCallback(Object* pSender) 
{ 
    Size size = Director::sharedDirector()->getWinSize(); 
 
    //显示关于的内容 
    LabelTTF* label = LabelTTF::create("Made by LJW", "Arial", 30); 
    label->setPosition(Point(size.width / 2, size.height / 2)); 
    Scene* s = Scene::create(); 
    Layer* layer = Layer::create(); 
    layer->addChild(label, 1); 
 
    //返回按钮 
    LabelTTF* pBackLabel = LabelTTF::create("Back", "Arial", 30);
    MenuItemLabel* pBackItem = MenuItemLabel::create(pBackLabel, this, menu_selector(HelloWorld::backGameCallback)); 
    Menu* pBackMenu = Menu::create(pBackItem, NULL); 
    pBackItem->setPosition(Point(size.width  - 50, 50)); 
    pBackMenu->setPosition(CCPointZero); 
    layer->addChild(pBackMenu, 1); 
 
    s->addChild(layer); 
 
    Director::sharedDirector()->replaceScene(s); 
    //s->release(); 
    //layer->release(); 
 
} 
开发者ID:ljwrx,项目名称:OurGame,代码行数:26,代码来源:HelloWorldScene.cpp

示例8: init

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

    Point visibleOrigin = Director::getInstance()->getVisibleOrigin();
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Size editBoxSize = Size(visibleSize.width - 20, 20);
    m_pEditBoxName = cocos2d::ui::EditBox::create(editBoxSize, cocos2d::ui::Scale9Sprite::create("green_edit.png"));
    m_pEditBoxName->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height * 3 / 4));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    m_pEditBoxName->setFont("Paint Boy", 15);
#else
    m_pEditBoxName->setFont("Arial", 15);
#endif
    m_pEditBoxName->setFontColor(Color3B::BLACK);
    m_pEditBoxName->setPlaceHolder("Name:");
    m_pEditBoxName->setPlaceholderFontColor(Color3B::WHITE);
    m_pEditBoxName->setMaxLength(8);
    m_pEditBoxName->setReturnType(cocos2d::ui::EditBox::KeyboardReturnType::DONE);
    m_pEditBoxName->setDelegate(this);
    this->addChild(m_pEditBoxName, 1);

    m_pEditBoxChannel = cocos2d::ui::EditBox::create(editBoxSize, cocos2d::ui::Scale9Sprite::create("green_edit.png"));
    m_pEditBoxChannel->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 2));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    m_pEditBoxChannel->setFont("Paint Boy", 15);
#else
    m_pEditBoxChannel->setFont("Arial", 15);
#endif
    m_pEditBoxChannel->setFontColor(Color3B::BLACK);
    m_pEditBoxChannel->setPlaceHolder("Channel:");
    m_pEditBoxChannel->setPlaceholderFontColor(Color3B::WHITE);
    m_pEditBoxChannel->setMaxLength(8);
    m_pEditBoxChannel->setReturnType(cocos2d::ui::EditBox::KeyboardReturnType::DONE);
    m_pEditBoxChannel->setDelegate(this);
    this->addChild(m_pEditBoxChannel, 2);

    Label *label = Label::createWithSystemFont("Login", "Arial", 20);

    void (*onloginCB)(Ref *ref) = &MLogin::onLogin;

    MenuItemLabel *pMenuItem = MenuItemLabel::create(label, onloginCB);// const ccMenuCallback &callback
    Menu *pMenu = Menu::create(pMenuItem, NULL);
    pMenu->setPosition(Vec2(0,0));
    pMenuItem->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 4));
    this->addChild(pMenu, 1);

    Label *pLabel = Label::createWithSystemFont("pomelo-cocos2dchat", "Arial", 10);
    Size size = Director::getInstance()->getWinSize();
    pLabel->setPosition(Vec2(size.width / 2, size.height - 30));
    this->addChild(pLabel, 1);

    return true;
}
开发者ID:wangbin-git,项目名称:pomelo-cocos2dxchat-v3,代码行数:60,代码来源:LoginScene.cpp

示例9: sizeof

CocosDenshionTest::CocosDenshionTest()
: _itmeMenu(NULL),
_beginPos(PointZero),
_soundId(0)
{
    std::string testItems[] = {
        "play background music",
        "stop background music",
        "pause background music",
        "resume background music",
        "rewind background music",
        "is background music playing",
        "play effect",
        "play effect repeatly",
        "stop effect",
        "unload effect",
        "add background music volume",
        "sub background music volume",
        "add effects volume",
        "sub effects volume",
        "pause effect",
        "resume effect",
        "pause all effects",
        "resume all effects",
        "stop all effects"
    };

    // add menu items for tests
    _itmeMenu = Menu::create();

    _testCount = sizeof(testItems) / sizeof(testItems[0]);

    for (int i = 0; i < _testCount; ++i)
    {
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//        LabelBMFont* label = LabelBMFont::create(testItems[i].c_str(),  "fonts/arial16.fnt");
//#else
        LabelTTF* label = LabelTTF::create(testItems[i].c_str(), "Arial", 24);
//#endif        
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(CocosDenshionTest::menuCallback, this));
        
        _itmeMenu->addChild(pMenuItem, i + 10000);
        pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
    }

    _itmeMenu->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, (_testCount + 1) * LINE_SPACE));
    _itmeMenu->setPosition(PointZero);
    addChild(_itmeMenu);

    setTouchEnabled(true);

    // preload background music and effect
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( MUSIC_FILE );
    SimpleAudioEngine::sharedEngine()->preloadEffect( EFFECT_FILE );
    
    // set default volume
    SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.5);
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:59,代码来源:CocosDenshionTest.cpp

示例10: init

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

    this->setKeypadEnabled(true);

    Size size = CCDirector::getInstance()->getWinSize();

    auto title = LabelTTF::create("Item", "Arial", 24);
    title->setPosition( Point(size.width / 2, size.height - 50));
    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
    MenuItemImage *pCloseItem = MenuItemImage::create(
                                        "b1.png",
                                        "b2.png",
                                        CC_CALLBACK_1(ItemLayer::menuBackCallback,this) );
    pCloseItem->setPosition( Point(pCloseItem->getContentSize().width / 2 , 50) );

    // create menu, it's an autorelease object
    auto pMenu = Menu::create(pCloseItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);
    
    // add next menu
    MenuItemImage *pNextItem = MenuItemImage::create(
                                                          "f1.png",
                                                          "f2.png",
                                                          CC_CALLBACK_1(ItemLayer::menuNextCallback,this) );
    pNextItem->setPosition( Point(size.width - pNextItem->getContentSize().width / 2, 50) );
    
    // create menu, it's an autorelease object
    Menu* pNextMenu = Menu::create(pNextItem, NULL);
    pNextMenu->setPosition(Point::ZERO);
    this->addChild(pNextMenu, 1);

    float step = 35;
    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        char buf[64];
		sprintf(buf, s_EventMenuItem[i].id.c_str(), itemid, counts[i]);
        
        auto label = LabelTTF::create(buf, "Arial", 30);
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label,  CC_CALLBACK_1(ItemLayer::eventMenuCallback,this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = size.height - step*i - 100;
        pMenuItem->setPosition( Point(size.width / 2, yPos));
    }

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

示例11: init

bool MenuLayer::init(){
    if (!Layer::init())
    {
        return false;
    }

    GameUtile::Pause();

    m_visibleSize = Director::getInstance()->getVisibleSize();
    //Ìí¼Ómenu°´Å¥
    Label* labelSave = Label::create("Save", "Comic Sans MS", 30);
    MenuItemLabel* menuSave = MenuItemLabel::create(labelSave, CC_CALLBACK_0(MenuLayer::saveGame, this));
    menuSave->setPosition(Vec2(m_visibleSize.width * 0.5, m_visibleSize.height * 0.7));

    Label* labelRead = Label::create("Read", "Comic Sans MS", 30);
    MenuItemLabel* menuRead = MenuItemLabel::create(labelRead, CC_CALLBACK_0(MenuLayer::readGame, this));
    menuRead->setPosition(Vec2(m_visibleSize.width * 0.5, m_visibleSize.height * 0.6));

    Label* labelMusic = Label::create("Muisc", "Comic Sans MS", 30);
    global->uiLayer->addChild(labelMusic, 110);

    Label* labelON = Label::create("ON", "Comic Sans MS", 30);
    Label* labelOFF = Label::create("OFF", "Comic Sans MS", 30);
    MenuItemLabel* menuMusic0 = MenuItemLabel::create(labelON, CC_CALLBACK_0(MenuLayer::musicON, this));
    MenuItemLabel* menuMusic1 = MenuItemLabel::create(labelOFF, CC_CALLBACK_0(MenuLayer::musicOFF, this));
    menuMusic0->setPosition(Vec2(m_visibleSize.width * 0.5, m_visibleSize.height * 0.5));
    menuMusic1->setPosition(Vec2(m_visibleSize.width * 0.6, m_visibleSize.height * 0.5));

    Label* labelReturn = Label::create("Return", "Comic Sans MS", 30);
    MenuItemLabel* menuReturn = MenuItemLabel::create(labelReturn, CC_CALLBACK_0(MenuLayer::returnGame, this));
    menuReturn->setPosition(Vec2(m_visibleSize.width * 0.5, m_visibleSize.height * 0.4));

    Label* labelExit = Label::create("Exit Game", "Comic Sans MS", 30);
    MenuItemLabel* menuExit = MenuItemLabel::create(labelExit, CC_CALLBACK_0(MenuLayer::exitGame, this));
    menuExit->setPosition(Vec2(m_visibleSize.width * 0.5, m_visibleSize.height * 0.3));

    Menu* menu0 = Menu::create(menuSave, menuRead, menuMusic0, menuMusic1, menuReturn, menuExit, NULL);
    menu0->setPosition(Vec2::ZERO);
    global->uiLayer->addChild(menu0, 110);
    menu0->setTag(0);



    return true;
}
开发者ID:LettyLin,项目名称:Gear,代码行数:45,代码来源:MenuLayer.cpp

示例12: init

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

    _pluginAnalytics = NULL;
    loadPlugins();

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posBR = Point(origin.x + visibleSize.width, origin.y);

    /////////////////////////////
    // 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
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);

    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = visibleSize.height - 35*i - 100;
        pMenuItem->setPosition( Point(visibleSize.width / 2, yPos));
    }

    std::string strName = _pluginAnalytics->getPluginName();
    std::string strVer = _pluginAnalytics->getSDKVersion();
    char ret[256] = { 0 };
    sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
    LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), Label::HAlignment::CENTER);
    pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80));
    addChild(pLabel);

    return true;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:50,代码来源:TestAnalyticsScene.cpp

示例13: init

bool GameMenu::init(void)
{
    Size sizeWin = Director::getInstance()->getWinSize();

    Menu* pItemMenu = Menu::create();

    //TTFConfig ttfConfig(CF_F("fonts_en").c_str(), 48);
    TTFConfig ttfConfig2(CF_F("fonts_cn").c_str(), CF_FT("font_menu"));

    auto label = Label::createWithTTF(ttfConfig2, CF_S("label_normal_start"));
    MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(GameMenu::menuNormalGameCallback, this));

    auto labelInput = Label::createWithTTF(ttfConfig2, CF_S("label_login"));
    MenuItemLabel* pMenuInput = MenuItemLabel::create(labelInput, CC_CALLBACK_1(GameMenu::menuUserLoginCallback, this));

    auto labelLan = Label::createWithTTF(ttfConfig2, CF_S("label_net_start"));
    MenuItemLabel* pMenuItemLanTest = MenuItemLabel::create(labelLan, CC_CALLBACK_1(GameMenu::menuNetGameCallback, this));

    pItemMenu->addChild(pMenuItem);
	pItemMenu->addChild(pMenuInput);
	pItemMenu->addChild(pMenuItemLanTest);
	pMenuItem->setPosition(0, sizeWin.height * CF_P("pos_main_start"));
    pMenuInput->setPosition(0, sizeWin.height * CF_P("pos_main_login"));
	pMenuItemLanTest->setPosition(0, sizeWin.height * CF_P("pos_main_netstart"));

    pItemMenu->setPositionY(0);
    this->addChild(pItemMenu);

    MenuItemImage *pCloseItem = MenuItemImage::create(CF_F("image_closeNormal"), CF_F("image_closeSelect"),
        CC_CALLBACK_1(GameMenu::menuCloseCallback, this));
    Menu* pCloseMenu = Menu::create(pCloseItem, NULL);
    pCloseMenu->setPositionY(sizeWin.height * CF_P("pos_main_close"));
    this->addChild(pCloseMenu);

	return true;
}
开发者ID:coderHsc,项目名称:ChineseChessCC,代码行数:36,代码来源:GameMenu.cpp

示例14: onEnter

void CocostudioParserJsonScene::onEnter()
{
    CCScene::onEnter();
    
    auto label = Label::createWithTTF("Back", "fonts/arial.ttf", 20);
    //#endif
    MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(CocostudioParserJsonScene::BackCallback, this));
    
    Menu* pMenu = Menu::create(pMenuItem, nullptr);
    
    pMenu->setPosition( Vec2::ZERO );
    pMenuItem->setPosition(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25);
    
    addChild(pMenu, 1);
}
开发者ID:AnySDK,项目名称:Sample_Lua,代码行数:15,代码来源:CocostudioParserJsonTest.cpp

示例15: onEnter

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

    //add the menu item for back to main menu
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
//    LabelBMFont* label = LabelBMFont::create("MainMenu",  "fonts/arial16.fnt");
//#else
    LabelTTF* label = LabelTTF::create("MainMenu", "Arial", 20);
//#endif
    MenuItemLabel* pMenuItem = MenuItemLabel::create(label, [](Object *sender) {
        /*
            ******    GCC Compiler issue on Android and Linux (CLANG compiler is ok)   ******
        We couldn't use 'Scene::create' directly since gcc will trigger
        an error called "error: 'this' was not captured for this lambda function".
        This is because 'Scene' is the super class of TestScene, if we invoke 'Scene::create'
        directly in this lambda expression, gcc compiler found 'Scene::create' and it think
        that was the member function of 'TestScene' 's super class, but this lambda function doesn't
        capture anything like 'this', so it has no access to invoke 'Scene::create'.
         
        Solution (1): Passing 'this' to this lambda function.
        Solution (2): Don't use 'Scene::create' and don't pass 'this' to this lambda function,
                      instead, we just need to new the 'Scene' and initialize the Scene.
         
        Semantically, I think in this lambda function, we shouldn't capture any varibles
                      outside the scope. So I choose the (2) solution. Commented by James Chen.
        */

//        Scene *pScene = Scene::create();
        Scene *pScene = new Scene();
        if (pScene && pScene->init())
        {
            Layer* pLayer = new TestController();
            pScene->addChild(pLayer);
            pLayer->release();
            Director::sharedDirector()->replaceScene(pScene);
            pScene->release();
        }
	});

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

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

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


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