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


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

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


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

示例1: checkCard

void MarketScene::checkCard(int index)
{
	CCMenu *pMenu = (CCMenu *)this->getChildByTag(TAG_MENU);

	char szFileName[32] = { 0 };
	for (int i = 0; i < CARD_COUNT; i++)
	{
		int tag = BTN_CARD + i;
		CCMenuItemToggle *pToggle = (CCMenuItemToggle *)pMenu->getChildByTag(tag);

		if (tag == index)
		{
			selectedIndex = index;
			pToggle->setSelectedIndex(1);
			pToggle->setEnabled(false);
			sprintf(szFileName, s_pathCardInfo.m_strPath, i);

			int price = getPrice(tag);
			updateLabelAtlas(price, LabelAtlas_PRICE);

			CCMenuItemImage *pMenuItem = (CCMenuItemImage *)pMenu->getChildByTag(BTN_BUY);
			if (g_Control.cards[i] <= 0 && g_Control.m_nCoin > price)
			{
				pMenuItem->setEnabled(true);
			}
			else
			{
				pMenuItem->setEnabled(false);
			}
		}
		else
		{
			pToggle->setSelectedIndex(0);
			pToggle->setEnabled(true);
		}
	}

	this->removeChildByTag(CARD_INFO);
	CCSprite *pcdSprite = CCSprite::create(szFileName);
	pcdSprite->setPosition(s_pathCardInfo.m_Position);
	pcdSprite->setTag(CARD_INFO);
	this->addChild(pcdSprite);
	pcdSprite->runAction(CCSequence::create(CCSpawn::create(CCScaleTo::create(0.2f, 1.0f), CCFadeTo::create(0.2f, 255), NULL), NULL));
}
开发者ID:hyper123,项目名称:TurboSnail,代码行数:44,代码来源:MarketScene.cpp

示例2: init

bool BossSnakePlay::init() {
    if (!SnakesPlay::init())
        return false;

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

    // init the map
    VirtualMap::init();

	BarrierFactory barrierfactory;
	m_barrier = barrierfactory.createBarrier(this,BarrierFactory::BARRIER_TYPE_BOSS);

    // create snakes
	SnakeFactory snakefactory;
	Snake *snake = snakefactory.createSimpleSnake(this,SnakeFactory::SNAKEIMG_TYPE_WHITE,1);
    m_snakes.push_back(snake);
	snake = snakefactory.createBossSnake(this,SnakeFactory::SNAKEIMG_TYPE_BOSS,2);
    m_snakes.push_back(snake);

	// generate food
    FoodFactory *foodfactory = new MultiFoodFactory();
	m_food = foodfactory->createFood(this);
    m_food->generate();

	// create control
	m_controls.push_back(new HumanControl());
    m_controls.push_back(m_food);

    // game control button
    m_stopFlag = false;
    CCMenuItemImage *StopGameItem = CCMenuItemImage::create("buttons/pause.png", "buttons/pause.png");
    CCMenuItemImage *StartGameItem = CCMenuItemImage::create("buttons/play.png", "buttons/play.png");
    CCMenuItemToggle *StopOrStartItem = CCMenuItemToggle::createWithTarget(this,menu_selector(SnakesPlay::StopGameCallback), StopGameItem,StartGameItem, NULL);
    StopOrStartItem->setEnabled(true);
    StopOrStartItem->setScale(0.5);

    CCMenu* itemToggleMenu = CCMenu::create(StopOrStartItem, NULL);
    itemToggleMenu->setPosition(ccp(visibleSize.width-20, 20));
    this->addChild(itemToggleMenu, 1);

    this->schedule(schedule_selector(BossSnakePlay::scheUpdate),m_updateTime);

    return true;
}
开发者ID:JNU-Trio,项目名称:BabySnakes,代码行数:44,代码来源:BossSnakePlay.cpp


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