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


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

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


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

示例1: initNavigator

void GamePlayScene::initNavigator() {
    MenuItemFont *menuTitle = MenuItemFont::create(Constant::MENU_PLAY, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    menuTitle->setFontName(Constant::FONT);
    menuTitle->setFontSize(64);
    menuTitle->setVisible(false);

    MenuItemFont *back = MenuItemFont::create(Constant::MENU_BACK, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    back->setFontName(Constant::FONT);
    back->setFontSize(64);
    back->setTag(Constant::MENU_BACK_TAG);

    MenuItemFont *start = MenuItemFont::create(Constant::MENU_START, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    start->setFontName(Constant::FONT);
    start->setFontSize(64);
    start->setTag(Constant::MENU_START_TAG);

    Menu *menu = Menu::create(back, start, NULL);
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    back->setPosition(Vec2(origin.x + visibleSize.width - back->getContentSize().width / 2,
                                    origin.y + back->getContentSize().height / 2));
    start->setPosition(Vec2(origin.x + start->getContentSize().width / 2,
                                    origin.y + back->getContentSize().height / 2));
    menu->setPosition(Vec2::ZERO);
    addChild(menu);
}
开发者ID:ArthasJin,项目名称:trizzle,代码行数:26,代码来源:GamePlayScene.cpp

示例2: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
//    auto rootNode = CSLoader::createNode("MainScene.csb");
//
//    addChild(rootNode);
    
    
//    Sprite *s = Sprite::create("whah");
//    this->addChild(s);
    
//    MenuItemFont *item = MenuItemFont::create("ylyTest 按钮 01");
//    
//    Menu *m = Menu::create(item,NULL);
//    
//    this->addChild(m);
//
//    return true;
//}
    
//    Vec2 winSize = Director::getInstance()->getWinSize();
    
    // 可见视图大小
//    Size visiblesSize = Director::getInstance()->getVisibleSize();
    
    MenuItemFont *item = MenuItemFont::create("开始游戏",CC_CALLBACK_1(HelloWorld::onMenuItem,this));
    
    MenuItemFont *gameMap = MenuItemFont::create("游戏地图",CC_CALLBACK_1(HelloWorld::onMenuItemGameMap,this));
    
//    gameMap->setPosition(Vec2(visiblesSize.width/2, visiblesSize.height/2-30));
    
//    gameMap->setAnchorPoint(Vec2(visiblesSize.width/2, visiblesSize.height/2-30));
    // 锚点和位置
//    gameMap->setAnchorPoint(Vec2::ZERO);
    
    gameMap->setPosition(Vec2(0.0, -50));
    
    
    MenuItemFont *myGame = MenuItemFont::create("myGame",CC_CALLBACK_1(HelloWorld::onMenuItemMyGame,this));
    myGame->setPosition(Vec2(0.0, -100));
    
    MenuItemFont *testMyGameA = MenuItemFont::create("testMyGameA*",CC_CALLBACK_1(HelloWorld::onMenuItemTestMyGame,this));
    testMyGameA->setPosition(Vec2(0.0, -150));

    
    Menu *menu = Menu::create(item,gameMap,myGame,testMyGameA,NULL);
    
    
    this->addChild(menu);
    
    return true;
}
开发者ID:MoonRaito,项目名称:cocos2dx,代码行数:59,代码来源:HelloWorldScene.cpp

示例3: init

// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::sharedDirector()->getWinSize();

    TableView* tableView = TableView::create(this, CCSizeMake(250, 60));
    tableView->setDirection(kScrollViewDirectionHorizontal);
    tableView->setPosition(ccp(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, CCSizeMake(60, 250));
	tableView->setDirection(kScrollViewDirectionVertical);
	tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(kTableViewFillTopDown);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(PointZero);
	addChild(menuBack);

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

示例4: gameOver

// Menus
void GameLevelLayer::gameOver(bool playerDidWin)
{
	m_isGameOver = true;
    std::string gameText;
    
	if (playerDidWin)
    {
		gameText = "You Won!";
	}
    else
    {
		gameText = "You have Died!";
        CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("hurt.wav");
	}
    
    Menu* pMenu = CCMenu::create();
    pMenu->setPosition(Vec2(240, -100));
    
    MenuItemFont *diedLabel = MenuItemFont::create(gameText);
    diedLabel->setFontName("Marker Felt");
    diedLabel->setFontSize(24);
    diedLabel->setPosition(Vec2(240, 200));
    pMenu->addChild(diedLabel);
    
    MoveBy *slideIn = MoveBy::create(1.0, Vec2(0,250));
    
    MenuItemImage *replay = MenuItemImage::create("replay.png", "replay.png", "replay.png");
    replay->setPosition(Point::ZERO);
    replay->setCallback(CC_CALLBACK_1(GameLevelLayer::replayButtonCallback, this));
    pMenu->addChild(replay);
    
    this->addChild(pMenu, 1);
    
    pMenu->runAction(slideIn);
}
开发者ID:bluemaxmb,项目名称:SuperKoalio_Cocos2D-X_3.1,代码行数:36,代码来源:GameLevelLayer.cpp

示例5: init

// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Point(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(Point::ZERO);
	addChild(menuBack);

    return true;
}
开发者ID:aberaud,项目名称:cocos2d-x,代码行数:34,代码来源:TableViewTestScene.cpp

示例6: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 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
 //   auto closeItem = MenuItemImage::create(
 //                                          "CloseNormal.png",
 //                                          "CloseSelected.png",
 //                                          CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
 //   
	//closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
 //                               origin.y + closeItem->getContentSize().height/2));

	MenuItemFont* buttonItem = MenuItemFont::create("menu item font", CC_CALLBACK_1(HelloWorld::showNewLayer, this));
	buttonItem->setPosition(visibleSize.width/2, visibleSize.height/2);

    // create menu, it's an autorelease object
	auto menu = Menu::create(buttonItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
    
    // position the label on the center of the screen
    label->setPosition(Vec2(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - label->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(label, 1);

    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);

    
    return true;
}
开发者ID:junhaesung,项目名称:newLayerTest,代码行数:61,代码来源:HelloWorldScene.cpp

示例7: createLevelEditorFilePopup

void UI::createLevelEditorFilePopup()
{
	Size visibleSize = Director::getInstance()->getVisibleSize();

	MenuItemFont* addTextureObject = MenuItemFont::create("choose file", CC_CALLBACK_0(UI::nullCallback, this));
	addTextureObject->setFontNameObj("Segoe UI");
	addTextureObject->setFontSizeObj(34);
	addTextureObject->setPosition(visibleSize.width * 0.5f, visibleSize.height - 30);

	MenuItemFont* scrollUpObject = MenuItemFont::create("up", CC_CALLBACK_0(LevelEditor::moveFileSelectUpCallback, pLevelEditor));
	scrollUpObject->setFontNameObj("Segoe UI");
	scrollUpObject->setFontSizeObj(34);
	scrollUpObject->setPosition(visibleSize.width - 50, visibleSize.height - 30);

	MenuItemFont* scrollDownObject = MenuItemFont::create("down", CC_CALLBACK_0(LevelEditor::moveFileSelectDownCallback, pLevelEditor));
	scrollDownObject->setFontNameObj("Segoe UI");
	scrollDownObject->setFontSizeObj(34);
	scrollDownObject->setPosition(visibleSize.width - 50, 30);

	MenuItemImage* scrollBackground = MenuItemImage::create("Resources/pictures/generic/ui_background.png", "ui_background.png", CC_CALLBACK_0(UI::nullCallback, this));
	scrollBackground->setPosition(visibleSize.width * 0.5f, visibleSize.height * 0.5f);
	scrollBackground->setScale(400, visibleSize.height);

	int paddingTop = 60;
	Vector<MenuItem*> lMenuItems;
	lMenuItems.pushBack(addTextureObject);
	for (string s : getAllFilesInFolder("Resources/pictures/tiles"))
	{
		MenuItemFont* menuItem = MenuItemFont::create(s, CC_CALLBACK_1(LevelEditor::chooseFileCallback, pLevelEditor, s, levelType));
		menuItem->setFontNameObj("Segoe UI");
		menuItem->setFontSizeObj(24);
		menuItem->setPosition(visibleSize.width * 0.5f, visibleSize.height - paddingTop);
		paddingTop += 30;
		lMenuItems.pushBack(menuItem);
	}
	auto menu = Menu::createWithArray(lMenuItems);
	auto scrollMenu = Menu::create(scrollBackground, scrollDownObject, scrollUpObject, NULL);
	scrollMenu->retain();
	scrollMenu->setPosition(0, 0);
	menu->retain();
	menu->setPosition(0, 0);
	m_pLevelEditor->addChild(menu);
	m_pLevelEditor->addChild(scrollMenu, -10);
	pLevelEditor->ChooseFileMenu = menu;
	pLevelEditor->ChooseFileNavMenu = scrollMenu;
}
开发者ID:destiny14,项目名称:FlyingSquirrel,代码行数:46,代码来源:UI.cpp

示例8: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    
	Size visibleSize = Director::getInstance()->getVisibleSize();

	MenuItemFont* pIncrease = MenuItemFont::create("increase 20",CC_CALLBACK_1(HelloWorld::increaseCallback,this));
	pIncrease->setAnchorPoint(Vec2(0.0f,1.0f));
	pIncrease->setPosition(0.0f,visibleSize.height - 0.0f);


	MenuItemFont* pReduce   = MenuItemFont::create("reduce 20",CC_CALLBACK_1(HelloWorld::reduceCallback,this));
	pReduce->setAnchorPoint(Vec2(0.0f,1.0f));
	pReduce->setPosition(0.0f,visibleSize.height - 40.0f);

	MenuItemFont* pGoto     = MenuItemFont::create("goto 100",CC_CALLBACK_1(HelloWorld::gotoCallback,this));
	pGoto->setAnchorPoint(Vec2(0.0f,1.0f));
	pGoto->setPosition(0.0f,visibleSize.height - 80.0f);

	Menu* pMenu = Menu::create(pIncrease,pReduce,pGoto, NULL);
	pMenu->setPosition(Vec2(0.0f,0.0f));
    this->addChild(pMenu, 1);


	LabelAtlas* pNumber = LabelAtlas::create("","number.png",55,84,'0');
	pNumber->setAnchorPoint(Vec2(0.5f,0.5f));
	pNumber->setPosition(Vec2(visibleSize.width/2.0f,
                             visibleSize.height/2.0f));

	this->addChild(pNumber);

	m_numberCount.setLabelAtlas(pNumber); //如果是从cocostudio导出的话请调用NumberCount::setTextAtlas

	//将数字每一步的增量初始化为3
	m_numberCount.setNumberDelta(3);

	//将数字增加时间间隔设置为0.1秒
	m_numberCount.setTimeDelta(0.1f);

	//将数字初始化为100
	m_numberCount.setNumber(100,false);
    return true;
}
开发者ID:0xiaohui00,项目名称:Cocos2dxUsefulClasses,代码行数:47,代码来源:HelloWorldScene.cpp

示例9: gameLogic

// ゲームメイン処理
void PlayScene::gameLogic(){
    // 画像描画用に画面のサイズと座標開始位置を取得
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    // ゲームオブジェクトの追加とそのアニメーション処理
    schedule(schedule_selector(PlayScene::addGameObject), 2.0);
    

    // クリアボタン作成
    MenuItemFont* clearButton = MenuItemFont::create("CLEAR!",
                                                      [this](Ref *pSender){
                                                          float duration = 1.0f;
                                                          Scene* pScene = TransitionFadeDown::create(duration, EndingScene::createScene());
                                                          Director::getInstance()->replaceScene(pScene);
                                                      });
    
    
    clearButton->setPosition(Vec2(origin.x + ( visibleSize.width / 3) * 2 + ( clearButton->getContentSize().width / 2 ) ,
                                  origin.y + ( visibleSize.height / 5) * 2 ));
    
    // ゲームオーバーボタン作成
    MenuItemFont* gameOverButton = MenuItemFont::create("GAMEOVER!",
                                                     [this](Ref *pSender){
                                                         float duration = 1.0f;
                                                         Scene* pScene = TransitionJumpZoom::create(duration, GameOverScene::createScene());
                                                         Director::getInstance()->replaceScene(pScene);
                                                     });
    
    
    gameOverButton->setPosition(Vec2(origin.x + ( visibleSize.width / 3) * 2 + ( gameOverButton->getContentSize().width / 2 ) ,
                                     origin.y + ( visibleSize.height / 5) * 3));

    
    
    // 作成したボタンの追加
    Menu* menu = Menu::create(clearButton, gameOverButton, NULL);
    menu->setPosition(0,0);
    this->addChild(menu);
}
开发者ID:UenoTAKAFUMI,项目名称:BaseGame,代码行数:41,代码来源:PlayScene.cpp

示例10: init

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

    MyPurchase::getInstance()->loadIAPPlugin();

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

    auto pEGLView = Director::getInstance()->getOpenGLView();
    Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
    Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::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);

    Point posStep = Point(220, -150);
    Point beginPos = posTL + (posStep * 0.5f);
    int line = 0;
    int row = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
    	MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
    			CC_CALLBACK_1(TestIAP::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);

        Point pos = beginPos + Point(posStep.x * row, posStep.y * line);
        Size itemSize = pMenuItem->getContentSize();
        if ((pos.x + itemSize.width / 2) > posBR.x)
		{
			line += 1;
			row = 0;
			pos = beginPos + Point(posStep.x * row, posStep.y * line);
		}
        row += 1;
        pMenuItem->setPosition(pos);
    }

    return true;
}
开发者ID:LeeWei92,项目名称:cocos2dx-3.2-qt,代码行数:53,代码来源:TestIAPScene.cpp

示例11: init

bool MDPauseMenu::init(MDPauseMenuInterfaz* target)
{
    if (CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
    {
        mTarget = target;
        
        Size visibleSize  = Director::getInstance()->getVisibleSize();
        
        // Menu items
        MenuItemFont *btResume = MenuItemFont::create("Resume",
                                                          this,
                                                          menu_selector(MDPauseMenu::resumeGame));
        btResume->setColor(ccc3(255, 255, 255));
        btResume->setAnchorPoint(ccp(0.5, 1));
		btResume->setPosition(ccp(0, 0));
        
        MenuItemFont *btRetry = MenuItemFont::create("Retry",
                                                          this,
                                                          menu_selector(MDPauseMenu::retryGame));
        btRetry->setColor(ccc3(255, 255, 255));
		btRetry->setAnchorPoint(ccp(0.5, 1));
		btRetry->setPosition(ccp(0, btResume->getPosition().y - btResume->getContentSize().height - MENU_ITEMS_SPACING));

        MenuItemFont *btExit = MenuItemFont::create("Exit",
                                                          this,
                                                          menu_selector(MDPauseMenu::quitGame));
        btExit->setColor(ccc3(255, 255, 255));
		btExit->setAnchorPoint(ccp(0.5, 1));
		btExit->setPosition(ccp(0, btRetry->getPosition().y - btRetry->getContentSize().height - MENU_ITEMS_SPACING));
        
        // Menu
        Menu *menu = Menu::create(btResume, btRetry, btExit, NULL);
		menu->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
        addChild(menu);
        
        return true;
    }
    return false;
}
开发者ID:zhangchu1994,项目名称:HelloWorldCpp3.5,代码行数:39,代码来源:MDPauseMenu.cpp

示例12: init

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

    const Size &size=Director::getInstance()->getWinSize();
    
    //灰色背景
    LayerColor* backLayerColor = LayerColor::create(Color4B(25, 25, 25, 125));
    this->addChild(backLayerColor);

    // 暂停
    MenuItemFont *menuItemPause = MenuItemFont::create("Continue", CC_CALLBACK_1(PauseLayer::menuContinueCallBack, this));
    menuItemPause->setPosition(Point(size.width / 2 - 100, size.height / 2));
   // 重新开始
    MenuItemFont *menuItemRestart = MenuItemFont::create("Restart", CC_CALLBACK_1(PauseLayer::menuRestartCallBack, this));
    menuItemRestart->setPosition(Point(size.width / 2 + 100, size.height / 2));
    Menu *menu=Menu::create(menuItemPause, menuItemRestart, NULL);
    menu->setPosition(Point::ZERO);
    this->addChild(menu);

//不声明 不定义 ontouchbegan的使用方法
//    auto callback = [](Touch * ,Event *)
//    {
//        return true;
//    };
//    auto listener = EventListenerTouchOneByOne::create();
//    listener->onTouchBegan = callback;
//    listener->setSwallowTouches(true);
//    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,this);
    EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = CC_CALLBACK_2(PauseLayer::onTouchBegan, this);
    listener->setSwallowTouches(true);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

    return true;
}
开发者ID:Helen2423,项目名称:cocos2dx-snakeGame,代码行数:38,代码来源:PauseLayer.cpp

示例13: 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

示例14: init

bool ListLayer::init() {
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
    Point posBR = Point(origin.x + visibleSize.width, origin.y);
    Point posBL = Point(origin.x, origin.y);
    
    
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(ListLayer::onBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
    
    MenuItemFont *pMenuItem = MenuItemFont::create("Menu", CC_CALLBACK_1(ListLayer::onMenuCallback, this));
    Size menuSize = pMenuItem->getContentSize();
    pMenuItem->setPosition(posBL + Point(menuSize.width / 2, menuSize.height / 2));
    
    Menu* pMenu = Menu::create(pBackItem, pMenuItem, nullptr);
    pMenu->setPosition(Point::ZERO);
    addChild(pMenu, 1);
    
    _testListView = TableView::create(this, visibleSize);
    _testListView->setDelegate(this);
    _testListView->setPosition(posBL);
    _testListView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
    
    addChild(_testListView);
    
    return true;
}
开发者ID:Senspark,项目名称:CocosXtension,代码行数:36,代码来源:ListLayer.cpp

示例15: showInGameMenuLayer

void StoreScene::showInGameMenuLayer() {
	Size winSize = Director::getInstance()->getWinSize();

	InGameMenuLayer* _inGameMenuLayer = InGameMenuLayer::create();
	addChild(_inGameMenuLayer);

	MenuItemFont *menuButton = MenuItemFont::create("Menu", this,menu_selector(StoreScene::menuButtonCallback));
	menuButton->setColor(Color3B(0,0,0));

	menuButton->setPosition(Point(winSize.width - menuButton->getContentSize().width, winSize.height - menuButton->getContentSize().height));

	Menu *pMenu = Menu::create(menuButton,NULL);
	pMenu->setPosition(Point::ZERO);

	_inGameMenuLayer->addChild(pMenu, 1);
}
开发者ID:Playscape,项目名称:PublishingKit-Demo-Cocos2dx,代码行数:16,代码来源:StoreScene.cpp


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