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


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

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


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

示例1: init

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

	// ask director the window size
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	float scale = MultiResolution::getScale();
	/////////// Menu ////////////
	CCLabelBMFont* labelStart = CCLabelBMFont::create("Start", "futura-48.fnt");
	CCMenuItemLabel* pStartItem = CCMenuItemLabel::create(labelStart, this, menu_selector(MainMenu::menuStartCallback));
	pStartItem->setPosition(ccp(size.width/2, size.height/2));
	pStartItem->setScale(scale);

	CCLabelBMFont* labelOptions = CCLabelBMFont::create("Options", "futura-48.fnt");
	CCMenuItemLabel *pOptionsItem = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::menuOptionsCallback));
	pOptionsItem->setPosition(ccp(size.width/2, size.height/2 - pStartItem->getContentSize().height*scale));
	pOptionsItem->setScale(scale);

	CCLabelBMFont* labelExit = CCLabelBMFont::create("Exit", "futura-48.fnt");
	CCMenuItemLabel *pExitItem = CCMenuItemLabel::create(labelExit, this, menu_selector(MainMenu::menuCloseCallback));
	pExitItem->setPosition(ccp(size.width/2, size.height/2 - 2*pStartItem->getContentSize().height*scale));
	pExitItem->setScale(scale);

	CCMenu* pMenu = CCMenu::create(pStartItem, pOptionsItem, pExitItem, NULL);
	pMenu->setPosition( CCPointZero );
	this->addChild(pMenu, 1);
	/////////////////////////////

	//////////// Game title and background image  ////////////
	CCLabelBMFont* pLabel = CCLabelBMFont::create("Crack Code", "futura-48.fnt");

	// position the label on the center of the screen
	pLabel->setPosition( ccp(size.width / 2, size.height - 50*scale) );
	pLabel->setScale(scale+0.3);

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

	// add "MainMenu" splash screen"
	CCSprite* pSprite = CCSprite::create("safe_background.jpg");

	// position the sprite on the center of the screen
	pSprite->setPosition( ccp(size.width / 2, size.height / 2) );

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

	return true;
}
开发者ID:TigranOg,项目名称:CrackCode,代码行数:56,代码来源:MainMenuScene.cpp

示例2: makeMenu

void ConfigMenu::makeMenu(){
	CCMenuItemFont::setFontSize(50);
	CCMenuItemFont::setFontName("Arial");


	//CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback), 
		//CCMenuItemFont::create("Music OFF"),
		//CCMenuItemFont::create("Music ON"), NULL);
	CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback),
		CCMenuItemLabel::create(CCLabelBMFont::create("Music OFF", "arial-unicode-26.fnt", 300)), 
		CCMenuItemLabel::create(CCLabelBMFont::create("Music ON", "arial-unicode-26.fnt", 300)), NULL);
	
	CCLabelBMFont* txtShare = CCLabelBMFont::create("Share", "arial-unicode-26.fnt", 300);
	//CCMenuItemFont* share = CCMenuItemFont::create("Share", this, menu_selector(ConfigMenu::shareMenuCallback));
	//CCLabelTTF* d = CCLabelTTF::create("Share", "Arial", 30);
	CCMenuItemLabel* share = CCMenuItemLabel::create(txtShare, this, menu_selector(ConfigMenu::shareMenuCallback));
	music->setPosition(ccp(0,-60));
	share->setPosition(ccp(0, music->getContentSize().height+music->getPositionY()+20));
	share->setScale(2);
	music->setScale(2);
	CCMenu *menu = CCMenu::create(music, share, NULL);
	//menu->setPosition(ccp(400,0));
	menu->setOpacity(kCCMenuHandlerPriority);
	this->addChild(menu);
	if(!CCUserDefault::sharedUserDefault()->getBoolForKey(CONFIG_KEY_HAS_MUSIC)){
		music->setSelectedIndex(1);
	}else{
		music->setSelectedIndex(0);
	}

}
开发者ID:laogong5i0,项目名称:MiniGame,代码行数:31,代码来源:ConfigMenu.cpp

示例3: init

bool Options::init()
{
    if (!CCLayer::init()) {
        return false;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *sp = CCSprite::create(s_loading);
    sp->setAnchorPoint(CCPointZero);
    addChild(sp, 0, 1);
    
    CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
    CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 0, 134, 34));
    title->setPosition(ccp(winSize.width/2, winSize.height - 60));
    addChild(title);

    CCMenuItemFont *menuTitle = CCMenuItemFont::create("Sound");
    menuTitle->setFontName("Arial");
    menuTitle->setFontSize(18);
    menuTitle->setEnabled(false);
    
    CCMenuItemFont::setFontName("Arial");
    CCMenuItemFont::setFontSize(26);
    CCMenuItemToggle *toggle = CCMenuItemToggle::createWithTarget(this, menu_selector(Options::setOptions), CCMenuItemFont::create("On"),CCMenuItemFont::create("Off"), NULL);
    
    int selectId = Config::sharedConfig()->getAudioState()? 0 : 1;
    toggle->setSelectedIndex(selectId);
    
    CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
    CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(Options::goBack));
    goBack->setScale(0.6);
    CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
    CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
    CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
    CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
    CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
    // 这里也是,参数必须强转,否则NDK编译不过
    goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
    
    CCMenu *menu = CCMenu::create( menuTitle, toggle, goBack, NULL);
    menu->alignItemsInColumns(2,1);
    addChild(menu);

    
    CCPoint pos =  goBack->getPosition();
    pos.y -= 50;
    goBack->setPosition(pos);
    
    
    return true;
}
开发者ID:897290110,项目名称:MoonWarriors,代码行数:52,代码来源:Options.cpp

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

示例5: init

bool About::init()
{
    if (!CCLayer::init()) {
        return false;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *sp = CCSprite::create(s_bg01);
    sp->setPosition(ccp(winSize.width / 2, winSize.height / 2));
    addChild(sp, 0, 1);
    
    CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
    CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 36, 100, 34));
    title->setPosition(ccp(winSize.width/2, winSize.height - 60));
    addChild(title);
    
    CCLabelTTF *about = CCLabelTTF::create("   Thanks to cocos2d!", "Arial Bold", 32, CCSizeMake(winSize.width * 0.85, 320), kCCTextAlignmentLeft);
    about->setPosition(ccp(winSize.width / 2, winSize.height / 2 ));
    addChild(about);
    
    
    CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
    CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(About::goBack));
    goBack->setScale(0.6f);
    CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
    CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
    CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
    CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
    CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
    // 参数必须要强转,不然ndk编译不过
    goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
    
    CCMenu *menu = CCMenu::create(goBack, NULL);
    menu->setPosition(winSize.width / 2, winSize.height/2 - 60);
    addChild(menu);
    
    return  true;
}
开发者ID:hu7433438,项目名称:BlackAndWhite,代码行数:39,代码来源:About.cpp

示例6: init

bool PauseLayer::init()
{
    // ccc4的最后一个参数才是透明度
    if (!CCLayerColor::initWithColor(ccc4(0, 0, 0, 100))) {
        return  false;
	}

	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -128, true);




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

	CCMenuItemImage *play = CCMenuItemImage::create("play.png", "play.png", this, menu_selector(PauseLayer::doResume));
	play->setScale(3);
	play->setPosition(ccp(winSize.width/2, winSize.height/2));

	//
	CCLabelBMFont *backLb = CCLabelBMFont::create("Main Layer", s_font);
	CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(PauseLayer::gotoSartLayer));
	goBack->setScale(0.6f);
	goBack->setPosition(ccp(winSize.width/2, goBack->getContentSize().height));

	mMenu = CCMenu::create(play, goBack, NULL);
	mMenu->setAnchorPoint(ccp(0, 0));
	addChild(mMenu, 1, 10);
	mMenu->setPosition(CCPointZero);

	mMenu->runAction(CCSequence::create(
		CCDelayTime::create(0.01f), 
		CCCallFunc::create(this, callfunc_selector(PauseLayer::schedule_menuPriority)),
		NULL));
    
    return true;
}
开发者ID:SongCF,项目名称:game-MoonWarriors,代码行数:36,代码来源:PauseLayer.cpp


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