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


C++ CCMenu::setPositionY方法代码示例

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


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

示例1: init

bool MainMenu::init()
{
	if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
    {
        return false;
    }

	CCLabelTTF *title = CCLabelTTF::create("Rabbit Run", FONT_NAME, 70);
	title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 80));
	this->addChild(title);

	CCMenuItemFont::setFontName(FONT_NAME);
	CCMenuItemFont::setFontSize(50);

	char* text[] = {"Score", "Power", "Effect",
				   "+10", "+20%", "--",
	               "+20", "+40%", "grow up",
				   "+10", "+0", "lose weight",
	               "+0", "+0","hiding"};
	for(int i = 0; i < 15; i++)
	{
		CCLabelTTF *label = CCLabelTTF::create(text[i], FONT_NAME, 50);
		label->setPosition(ccp(400 + i%3*300, 550 - i/3*85));
		this->addChild(label);
	}
	char* img[] = {"cabbage.png", "carrot.png", "carrot_ice.png", "carrot_sterlth.png"};
	for(int i = 0; i < 4; i++)
	{
		CCSprite *sprite = CCSprite::create(img[i]);
		sprite->setScale(0.2f);
		sprite->setPosition(ccp(250, 450 - i*80));
		this->addChild(sprite);
	}
	CCMenuItemFont *startGame = CCMenuItemFont::create("Play", this, menu_selector(MainMenu::startGame));
	startGame->setColor(ccc3(0, 255,51));
	startGame->setPositionX(-90);

	CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(MainMenu::exitGame));
	exitGame->setColor(ccc3(255, 0, 0));
	exitGame->setPositionX(110);

	CCMenu *menu = CCMenu::create(startGame, exitGame, NULL);
	menu->setPositionY(120);
	menu->setTouchPriority(-201);
	this->addChild(menu);

	CCLabelTTF *powerBy = CCLabelTTF::create("Power by cocos2d-x", FONT_NAME, 50);
	powerBy->setAnchorPoint(ccp(1, 0));
	powerBy->setPosition(ccp(SCREEN_WIDTH, 0));
	this->addChild(powerBy);

	this->setTouchPriority(-200);
	this->setTouchMode(kCCTouchesOneByOne);
	this->setTouchEnabled(true);

	return true;
}
开发者ID:DanicaMeng,项目名称:RabbitRun,代码行数:57,代码来源:MainMenu.cpp

示例2: createMenu

void CMenuLayer::createMenu()
{
	CCMenuItemFont::setFontSize( 32 );
	CCMenuItemFont::setFontName("Courier New");

	setTouchEnabled(true);

	// Font Item
	CCMenuItem* quit = CCMenuItemImage::create( "images/CloseNormal.png", "images/CloseSelected.png", this, menu_selector(CMenuLayer::onQuit) );
	CCMenu* menu = CCMenu::create( quit, NULL);
	menu->alignItemsVertically();

	addChild( menu );

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

	menu->setPositionX( winSize.width - itemSize.width / 2 );
	menu->setPositionY( winSize.height - itemSize.height / 2 );
}
开发者ID:ClAndHHL,项目名称:cocos3d-x,代码行数:20,代码来源:MenuScene.cpp

示例3: onShow

void ChallengeAgainLayer::onShow(int round, int need)
{
	float totalWidth = 0.0;
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCSprite *app1 = CCSprite::create(g_sRelifeBGImage);
	app1->setAnchorPoint(ccp(0,0));
	app1->setPositionX(30);
	app1->setPositionY(s.height*0.5);
	this->addChild(app1);
	totalWidth += app1->getContentSize().width;

	NumberSprite * roundTip = NumberSprite::create("green60",round);
	roundTip->setAnchorPoint(ccp(0,0));
	roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
	roundTip->setPositionY(app1->getPositionY());
	this->addChild(roundTip);
	totalWidth += 4;
	totalWidth += roundTip->realWidth;

	CCSprite *app2 = CCSprite::create(g_sGuanBGImage);
	app2->setAnchorPoint(ccp(0,0));
	app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);
	app2->setPositionY(roundTip->getPositionY());
	this->addChild(app2);
	totalWidth += 4;
	totalWidth += app2->getContentSize().width;

	float bx = (s.width - totalWidth)*0.5;
	app1->setPositionX(bx);
	roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
	app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);

	CCSprite *app3 = CCSprite::create(g_sLifeNeedBGImage);
	app3->setAnchorPoint(ccp(0,0));
	app3->setPositionX(app1->getPositionX());
	app3->setPositionY(app2->getPositionY()-app2->getContentSize().height-20);
	this->addChild(app3);

	NumberSprite * needTip = NumberSprite::create("green60",need);
	needTip->setAnchorPoint(ccp(0,0));
	needTip->setPositionX(app3->getPositionX()+app3->getContentSize().width+4);
	needTip->setPositionY(app3->getPositionY());
	this->addChild(needTip);

	CCSprite *app4 = CCSprite::create(g_sLifeValueBGImage);
	app4->setAnchorPoint(ccp(0,0));
	app4->setPositionX(needTip->getPositionX()+needTip->realWidth+4);
	app4->setPositionY(needTip->getPositionY());
	this->addChild(app4);

	CCMenuItemImage* pSureMenu = CCMenuItemImage::create(
                                                g_sSureBGImage, 
                                                g_sSureBGImage, 
                                                this, 
                                                menu_selector(ChallengeAgainLayer::onCommandSure));
	pSureMenu->setAnchorPoint(ccp(0,0));
	CCMenu* pMenu = CCMenu::create(pSureMenu, NULL);
    this->addChild(pMenu);
	pMenu->setTouchPriority(-1000);
	pMenu->setAnchorPoint(ccp(0,0));
	pMenu->setPositionY(app4->getPositionY()-app4->getTextureRect().size.height-40);
	pMenu->setPositionX(100);


	CCSprite * img = CCSprite::create(g_sReturnBGImage);
	CCMenuItemImage* pReturnMenu = CCMenuItemImage::create(
                                                g_sReturnBGImage, 
                                                g_sReturnBGImage, 
                                                this, 
                                                menu_selector(ChallengeAgainLayer::onCommandReturn));
	pReturnMenu->setAnchorPoint(ccp(0,0));
	CCMenu* pMenu2 = CCMenu::create(pReturnMenu, NULL);
    this->addChild(pMenu2);
	pMenu2->setTouchPriority(-1000);
	pMenu2->setAnchorPoint(ccp(0,0));
	pMenu2->setPositionY(pMenu->getPositionY());
	pMenu2->setPositionX(s.width-img->getTextureRect().size.width-100);
}
开发者ID:zhulu-mike,项目名称:CrazyStar,代码行数:78,代码来源:ChallengeAgainLayer.cpp

示例4: init

bool SelectLevel::init()

{
    if(!SceneStyle::init())
        return false;

    ADSoundManager::playMusic(InfoStyles::MENU_MUSIC);

    //Get curren collection
    const Collection* current_collection;
    current_collection =LevelSaves::getInstance().getCollectionById(
                _collection_id);

    //Get the screen start of cordinates
    const CCPoint ORIGIN = ADScreen::getOrigin();
    const CCSize VISIBLE_SIZE = ADScreen::getVisibleSize();
    const float SCALE = ADScreen::getScaleFactor();
    float x_middle_of_sheet = (VISIBLE_SIZE.width-133/SCALE)/2 + ORIGIN.x;
    float padding = 25/SCALE;
    showBackground(BackgroundType::Dark);

    showButtonBack();
    //window title
    cocos2d::CCLabelTTF* title_select_collection;


    title_select_collection = CCLabelTTF::create(current_collection->getName().c_str(),
                                                 ADLanguage::getFontName(),
                                                 InfoStyles::SIZE_MENU_TITLE);
    title_select_collection->setPositionX(x_middle_of_sheet+padding*2);

    title_select_collection->setPositionY(ORIGIN.y +
                                          + VISIBLE_SIZE.height-padding*0.25f -
                                          title_select_collection->getContentSize().height*0.5f);

    title_select_collection->setColor(InfoStyles::COLOR_WHITE);
    this->addChild(title_select_collection);

    //menu
    CCMenu* menu =CCMenu::create();
    float position_menu_y = VISIBLE_SIZE.height -padding*0.25f -
            title_select_collection->getContentSize().height*0.5f;


    float collection_width = 0;
    float card_height = 0;
    float card_width = 0;
    int current_dificult;
    current_dificult = 0;
    for(unsigned int j = 0; j < 3; ++j)
    {
        current_dificult = j;
        Card* card;
        if (j == 0)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartEasy().getImage().c_str()),
                                _("select_level.easy"),
                                star_number,CardType::WithBorder);

        }
        else if (j == 1)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartMiddle().getImage().c_str()),
                                _("select_level.middle"),
                                star_number,CardType::WithBorder);

        }
        else if (j == 2)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartDifficult().getImage().c_str()),
                                _("select_level.difficult"),
                                star_number,CardType::WithBorder);

        }

        ADMenuItem* button_card = ADMenuItem::create(card);
        button_card->setAnchorPoint(ccp(0.5f,0.5f));
        float one_card_width = 340/SCALE;
        collection_width += one_card_width;
        card_height = button_card->getContentSize().height;
        card_width = button_card->getContentSize().width;
        button_card->setPositionY(ORIGIN.y+button_card->getContentSize().height*0.5f);
        button_card->setPositionX(one_card_width*j + button_card->getContentSize().width*0.5f);
        CollectionID id = current_collection->getID();
        button_card->setClickAction([id,current_dificult](){
            CCDirector::sharedDirector()->replaceScene(LevelScene::scene(id,current_dificult));

        });
        menu->addChild(button_card);

        card->setCardColor(LevelSaves::getInstance().getColor(_collection_id));
//.........这里部分代码省略.........
开发者ID:seagullua,项目名称:Kids-Words,代码行数:101,代码来源:SelectLevel.cpp

示例5: init

bool LayerWin::init()
{
    bool bRet = false;

    do
    {

        int curTitle = Global::shareGlobal()->curTitle;

        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
        CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();


        CC_BREAK_IF(!initWithColor(ccc4(250, 248, 239,255)));

        CCLabelTTF* label = CCLabelTTF::create(curTitle == 11 ? "YOU WIN!" : "GREAT!","Arial Bold",32,
            CCSize(visibleSize.width,visibleSize.height*0.7),kCCTextAlignmentCenter);

        CC_BREAK_IF(!label);

        label->setColor(ccc3(119,110,101));
        label->setPosition(ccp(origin.x+visibleSize.width/2,origin.y+visibleSize.height/2));

        this->addChild(label);

        float rectX = visibleSize.width*0.75;
        float rectY = rectX*0.45;
        ColorRect* pRect = ColorRect::create(ccc4(236, 196, 0, 255),rectX,rectY);

        pRect->setPosition(origin.x + (visibleSize.width-rectX)/2,origin.y+(visibleSize.height)/2);

        this->addChild(pRect);


        CCString *ssv = CCString::createWithFormat("%d",1 << curTitle);
        CCLabelTTF* scoreValue = CCLabelTTF::create(ssv->getCString(),"Arial Bold",32,CCSize(rectX,rectY),
            kCCTextAlignmentCenter);

        this->addChild(scoreValue);
        scoreValue->setPosition(ccp(pRect->getPositionX()+rectX*0.5,pRect->getPositionY()+rectY*0.3));

        CCString *sst = CCString::createWithFormat("SCORE:%d",Global::shareGlobal()->curScore);
        CCLabelTTF* score = CCLabelTTF::create(sst->getCString(),"Arial Bold",8,CCSize(rectX,rectY*0.5),
            kCCTextAlignmentCenter);
        this->addChild(score);
        score->setPosition(ccp(pRect->getPositionX()+rectX*0.5,pRect->getPositionY()));

        
        float menuX = rectX*0.45;
        float menuY = menuX*0.3;


        TitleRect *titleBack = TitleRect::create(ccc4(187, 173, 160, 255),menuX,menuY,"Back");
        CCMenuItemLabel *MenuBack = CCMenuItemLabel::create(titleBack,this,menu_selector(LayerWin::menuBack));

        TitleRect *titleAgain = TitleRect::create(ccc4(187, 173, 160, 255),menuX,menuY,"Try again");
        CCMenuItemLabel *MenuAgain = CCMenuItemLabel::create(titleAgain,this,menu_selector(LayerWin::menuAgain));

        CCMenu *menu = CCMenu::create(MenuBack,MenuAgain,NULL);

        menu->alignItemsHorizontallyWithPadding(rectX*0.1);

        menu->setPositionY(origin.y+visibleSize.height*0.2);

        this->addChild(menu);


        bRet = true;
    }while(0);

    return bRet;
}
开发者ID:guoyingbo,项目名称:Game2048,代码行数:72,代码来源:LayerWin.cpp


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