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


C++ UILayer::setTouchEnabled方法代码示例

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


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

示例1: onEnter

void Scene_GameItem::onEnter()
{
    CCLayer::onEnter();
    this->initData();
    
    //隐藏pk界面
    this->setPkView(false);
	CCSprite* pSpriteBG = (CCSprite*)getChildByTag(eGameItemTagBg);
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	//pSpriteBG->setPosition(ccp(visibleSize.width/2 , pSpriteBG->getContentSize().height/2 + origin.y));
	

	char str1[100]={0};
	switch(GameShare_Global::shareGlobal()->gameType)
	{
	case 1:
		sprintf(str1,"GameSceneBg1.json");
		break;
	case Game_Jelly:
		sprintf(str1,"GameSceneBg2.json");
		break;
	case Game_Fruit: 
		sprintf(str1,"GameSceneBg3.json");
		break;
	case Game_Link:
		sprintf(str1,"GameSceneBg4.json");
		break;
	case Game_TaiKo: 
		sprintf(str1,"GameSceneBg5.json");
		break;
	case Game_Cir:
		sprintf(str1,"GameSceneBg1.json");
		break;
	default:
		break;
	}

	UILayer* ul = UILayer::create();
	auto myLayout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile(CStringUtil::convertToUIResPath(str1).c_str()));
	ul->addWidget(myLayout);
	this->addChild(ul, 0, 100);
	ul->setTouchEnabled(false);

	int nGameType = GameShare_Global::shareGlobal()->gameType;
	if (nGameType==1)
	{
		UIImageView* pHill = dynamic_cast<UIImageView*>(ul->getWidgetByName("san"));
		UIImageView* pHill2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("san2"));
		//CCActionInterval*  actionTo = CCScaleTo::create(2.0f, 0.5f);
		CCActionInterval*  actionBy = CCScaleBy::create(1.0f, 1.0f, 1.1f);
		CCActionInterval*  actionBy2 = CCScaleBy::create(1.0f, 1.1f, 1.0f);
		CCFiniteTimeAction* seq = CCSequence::create(actionBy, actionBy->reverse(),NULL);
		CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
		CCFiniteTimeAction* seq1 = CCSequence::create(actionBy2, actionBy2->reverse(),NULL);
		CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq1);
		pHill->runAction(repeatForever);
		pHill2->runAction(repeatForever2);
	}
	else if (nGameType==2)
	{
		UIImageView*  pCloud = dynamic_cast<UIImageView*>(ul->getWidgetByName("yun2"));
		UIImageView*  pCloud2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("yun3"));
		CCActionInterval*  actionBy = CCScaleBy::create(1.5f, 1.2f, 1.0f);
		CCActionInterval*  actionBy2 = CCScaleBy::create(1.5f, 1.2f, 1.0f);
		CCFiniteTimeAction* seq1 = CCSequence::create(actionBy, actionBy->reverse(),NULL);
		CCFiniteTimeAction* seq2 = CCSequence::create(actionBy2, actionBy2->reverse(),NULL);
		CCActionInterval * repeatForever1 =CCRepeatForever::create((CCActionInterval* )seq1);
		CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq2);
		pCloud->runAction(repeatForever1);
		pCloud2->runAction(repeatForever2);
	}
	else if (nGameType==3)
	{
		UIImageView*  pSugar = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_15"));
		UIImageView*  pSugar1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_20"));
		CCRotateBy* actionBy2 = CCRotateBy::create(1.5f, -25.0f, -25.0f);
		CCRotateBy* actionBy1 = CCRotateBy::create(1.5f, -25.0f, -25.0f);
		CCFiniteTimeAction* seq1 = CCSequence::create(actionBy2, actionBy2->reverse(), NULL);
		CCFiniteTimeAction* seq2 = CCSequence::create(actionBy1, actionBy1->reverse(), NULL);
		CCActionInterval * repeatForever1 =CCRepeatForever::create((CCActionInterval* )seq1);
		CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq2);
		pSugar->runAction(repeatForever1);
		pSugar1->runAction(repeatForever2);

		//星星
		UIImageView*  pXx1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_23"));
		UIImageView*  pXx2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_32"));
		UIImageView*  pXx3 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_35"));
		UIImageView*  pXx4 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_39"));

		CCActionInterval*  actionBy3 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
		CCActionInterval*  actionBy4 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
		CCActionInterval*  actionBy5 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
		CCActionInterval*  actionBy6 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
		
		CCFiniteTimeAction* seq3 = CCSequence::create(actionBy3, actionBy3->reverse(),NULL);
		CCFiniteTimeAction* seq4 = CCSequence::create(actionBy4, actionBy4->reverse(),NULL);
		CCFiniteTimeAction* seq5 = CCSequence::create(actionBy5, actionBy5->reverse(),NULL);
		CCFiniteTimeAction* seq6 = CCSequence::create(actionBy6, actionBy6->reverse(),NULL);
		
//.........这里部分代码省略.........
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:101,代码来源:Scene_GameItem.cpp


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