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


C++ CCMenuItemFont::setEnabled方法代码示例

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


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

示例1: startClient

void SceneGame::startClient(CCObject*obj)
{
	if (Net::Connect("127.0.0.1"))
	{
		// 把棋子倒过来
		for (int i = 0; i < 32; i++)
		{
			Stone* s = _s[i];
			s->_row = 9 - s->_row;
			s->_col = 8 - s->_col;
			s->setPosition(s->fromPlate());
		}

		// 开始接收
		Net::RecvStart();
		schedule(schedule_selector(SceneGame::CheckRecv));

		Net::_isConnected = true;
		_bRedSide = false;
		CCMenuItemFont *font = (CCMenuItemFont *)obj;
		CCMenuItemFont *server = (CCMenuItemFont *)font->getUserObject();
		server->setEnabled(false);
		font->setEnabled(false);
	}
	else
	{
		CCLog("Connect failure....");
	}
}
开发者ID:dalechngame,项目名称:mygame,代码行数:29,代码来源:SceneGame.cpp

示例2: startServer

void SceneGame::startServer(CCObject*obj)
{
	CCMenuItemFont *font = (CCMenuItemFont *)obj;
	CCMenuItemFont *client = (CCMenuItemFont *)font->getUserObject();
	client->setEnabled(false);
	font->setEnabled(false);

	_bRedSide = true;
	Net::Accept();
	schedule(schedule_selector(SceneGame::CheckListen));
}
开发者ID:dalechngame,项目名称:mygame,代码行数:11,代码来源:SceneGame.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: init

// 主菜单Layer对象创建时初始化, 用来完成布局主菜单的功能。 包括背景图片、菜单、背景音乐加载等。
bool MainMenu::init()
{
	int remainder;  // 菜单顶部空白
	int divider;    // 菜单间空白
	int halfWidth;

	// 必须先执行基类的方法
	if(!CCLayer::init())
	{
		return false;
	}

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	halfWidth = winSize.width / 2;

	// 添加背景图片,放在最底层
	CCSprite* background = CCSprite::create("background.png");
	background->setPosition(ccp(halfWidth, winSize.height / 2));
	addChild(background, 0);

	CCSprite* title = CCSprite::create("title.png");
	title->setAnchorPoint(ccp(0.5, 1));
	title->setScale(0.5);
	title->setPosition(ccp(halfWidth, winSize.height - 20));
	addChild(title, 10);

	// 添加菜单
	CCMenuItemFont* startGame = CCMenuItemFont::create("start", this, menu_selector(MainMenu::startGame));
	CCSize contentSize = startGame->getContentSize();
	divider = contentSize.height;  // 菜单间间隔单项高度的1/3
	remainder = (winSize.height - divider * MAIN_MENU_NUM) * 3 / 5;
	startGame->setAnchorPoint(ccp(0.5, 1));
	startGame->setPosition(ccp(halfWidth, winSize.height - remainder));
	startGame->setEnabled(false);

	CCMenuItemFont* pauseGame = CCMenuItemFont::create("pause", this, menu_selector(MainMenu::pauseGame));
	pauseGame->setAnchorPoint(ccp(0.5, 1));
	pauseGame->setPosition(ccp(halfWidth, winSize.height - remainder - divider));
	pauseGame->setEnabled(false);
	pauseGame->setVisible(true);

	CCMenuItemFont* resumeGame = CCMenuItemFont::create("resume", this, menu_selector(MainMenu::resumeGame));
	resumeGame->setAnchorPoint(ccp(0.5, 1));
	resumeGame->setPosition(ccp(halfWidth, winSize.height - remainder - divider));
	resumeGame->setEnabled(false);
	resumeGame->setVisible(false);

	CCMenuItemFont* setting = CCMenuItemFont::create("setting", this, menu_selector(MainMenu::setting));
	setting->setAnchorPoint(ccp(0.5, 1));
	setting->setPosition(ccp(halfWidth, winSize.height - remainder - 2 * divider));
	setting->setEnabled(false);

	CCMenuItemFont* quit = CCMenuItemFont::create("quit", this, menu_selector(MainMenu::quit));
	quit->setAnchorPoint(ccp(0.5, 1));
	quit->setPosition(ccp(halfWidth, winSize.height - remainder - 3 * divider));
	quit->setEnabled(false);

	CCMenu* mainMenu = CCMenu::create(startGame, pauseGame, resumeGame, setting, quit, NULL);
	mainMenu->setPosition(CCPointZero);
	addChild(mainMenu, 11, MAIN_MENU_TAG);

	// 对背景音乐进行预加载及设置, 默认背景音乐开启
	isSound = true;
	SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str());
	SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
	SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str(), true);

	return true;
}
开发者ID:kyoky82,项目名称:FishingJoy,代码行数:70,代码来源:MainMenu.cpp


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