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


C++ AppDelegate::GetLayoutString方法代码示例

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


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

示例1: init

bool GameLayer::init()
{
	iTotalTime = 30;
	spCard.clear();//clear it first
	if (Layer::init())
	{

		//-----------------------------------Setup basic settings-----------------------------------------
		//get the origin point of the X-Y axis, and the visiable size of the screen
		Size visiableSize = Director::getInstance()->getVisibleSize();
		Point origin = Director::getInstance()->getVisibleOrigin();

		AppDelegate *app = (AppDelegate*)Application::getInstance();
		std::string sCSD = app->GetLayoutString();
		_rootNode = CSLoader::createNode("res/memory_game/flip" + sCSD + ".csb");
		addChild(_rootNode, 1);

		SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Flip_Level.plist");
		thetime = 0;
		iFirstCard = -1;
		iSecondCard = -1;

		//--------------------------------------Setup common gadgets-------------------------------------
		_nTlimit = 3; // total tools can be used in each game
		_nTlcount = app->getToolsNumberInfo(); // total tools user has
		_nLvl = app->GetUserLevel(); //totol tips can be used
		_fPerToNLvl = app->GetPercentToNextLevel(); //Percent to next level
		_lTtlScore = app->GetUserTotalScore();

		auto btnTips = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTips"));
		if (btnTips){
			btnTips->setTag(2001);
			btnTips->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
		}
		auto button_Main = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("button_Main"));
		if (button_Main){
			button_Main->setTag(2002);
			button_Main->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
		}
		auto btnTipsTools = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTipsTools"));
		if (btnTipsTools){
			btnTipsTools->setTag(2003);
			btnTipsTools->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
		}

		if (app->iGameMode == MobileGameMode::Theme_Mode){
			//button_Main->setVisible(false);
			//btnTips->setVisible(false);
		}
		auto timerLabel = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblTimer"));

		auto lvlbar = dynamic_cast<Sprite*> (_rootNode->getChildByName("lv_bar_4"));
		lvlbar->setAnchorPoint(Vec2(0, 0.5));
		lvlbar->setScaleX(_fPerToNLvl);

		if (app->getBGMstatus() == BGMusic_flag::ON)
		{
			app->StartBGMusic(BGM_GAME);
		}

		//----------------------------------create a random array------------------------------------
		int iDiv = iMaxCard / 2;
		int* array1 = new int[iMaxCard / 2];
		int* array2 = new int[iMaxCard / 2];
		int* unique_array = new int[iMaxCard];
		int* array4 = new int[iMaxCard];
		int i = 0;
		for (i = 0; i<iDiv; i++)
		{
			array1[i] = i;
			array2[i] = i;
		}
		randomArray(array1, iMaxCard / 2);
		randomArray(array2, iMaxCard / 2);
		for (i = 0; i<iMaxCard; i++)
		{
			unique_array[i] = i;
		}
		for (i = 0; i<iDiv; i++)
		{
			array4[i] = array1[i];
		}
		for (i = iDiv; i<iMaxCard; i++)
		{
			array4[i] = array2[i - iDiv];
		}
		randomArray(unique_array, iMaxCard);
		for (i = 0; i<iMaxCard; i++)
		{
			unique_array[i] = array4[unique_array[i]];
			log("i=%d,%d", i, array4[unique_array[i]]);
		}
		//setup brick content
		srand((unsigned)time(0));//set rand() with real
		int random = rand();
		sprintf(sFile[0], "%s", sGame[random%MUST_HAVE]);
		sprintf(sFile[1], "%s", sGame[MUST_HAVE + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);
		sprintf(sFile[2], "%s", sGame[MUST_HAVE + int((IMAGE_COUNT - MUST_HAVE) / 3) + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);
		sprintf(sFile[3], "%s", sGame[MUST_HAVE + int((IMAGE_COUNT - MUST_HAVE) / 3) * 2 + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);

//.........这里部分代码省略.........
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:101,代码来源:GameLayer.cpp

示例2: init

// on "init" you need to initialize your instance
bool RegisterView::init() 
{
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	std::string sCSD=app->GetLayoutString();

    _rootNode = CSLoader::createNode("res/register/RegisterLayer"+sCSD+".csb");

	addChild(_rootNode);

	auto btnFacebook = dynamic_cast<Button*>(_rootNode->getChildByName("btnFacebook"));
	btnFacebook->setTag(1001);
	btnFacebook->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	btnFacebook->setEnabled(false);

	auto btnTwitter = dynamic_cast<Button*>(_rootNode->getChildByName("btnTwitter"));
	btnTwitter->setTag(1002);
	btnTwitter->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	btnTwitter->setEnabled(false);

	auto btnBack2Login = dynamic_cast<Button*>(_rootNode->getChildByName("btnBack2Login"));
	if (btnBack2Login){
		btnBack2Login->setTag(2003);
		btnBack2Login->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	}
	auto btnCreate = dynamic_cast<Button*>(_rootNode->getChildByName("btnCreate"));
	if (btnCreate){
		btnCreate->setTag(2002);
		btnCreate->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	}
	auto btnCancel = dynamic_cast<Button*>(_rootNode->getChildByName("btnCancel"));
	if (btnCancel){
		btnCancel->setTag(2001);
		btnCancel->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	}
	auto textEMail = dynamic_cast<TextField*>(_rootNode->getChildByName("txtEMail"));
	auto textUserName = dynamic_cast<TextField*>(_rootNode->getChildByName("txtUserName"));
	auto textPassword=dynamic_cast<TextField*>(_rootNode->getChildByName("txtPassword"));
	auto textPasswordConfirm=dynamic_cast<TextField*>(_rootNode->getChildByName("txtConfPassword"));

	if (textEMail)
	{
		textEMail->setText("");
		textEMail->addEventListener(CC_CALLBACK_2(RegisterView::textFieldEvent, this, 1));
	}

	if (textUserName)
	{
		textUserName->setText("");
		textUserName->addEventListener(CC_CALLBACK_2(RegisterView::textFieldEvent, this, 2));
	}
	if (textPassword)
	{
		textPassword->setText("");
		textPassword->addEventListener(CC_CALLBACK_2(RegisterView::textFieldEvent, this, 3));
	}
	if (textPasswordConfirm)
	{
		textPasswordConfirm->setText("");
		textPasswordConfirm->addEventListener(CC_CALLBACK_2(RegisterView::textFieldEvent, this, 3));
	}
	auto btnTerm = dynamic_cast<Button*>(_rootNode->getChildByName("btnTerm"));
	auto btnPolicy = dynamic_cast<Button*>(_rootNode->getChildByName("btnPolicy"));

	if (btnTerm){
		btnTerm->setTag(2101);
		btnTerm->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	}
	if (btnPolicy){
		btnPolicy->setTag(2102);
		btnPolicy->addTouchEventListener(CC_CALLBACK_2(RegisterView::touchButton, this));
	}

	Sprite* imgBackground = Sprite::create(REGISTER_BACKGROUND);
	imgBackground->setAnchorPoint(Vec2(0, 0));
	imgBackground->setPosition(Vec2(0, 0));
	this->addChild(imgBackground, -1, 222);

	return true;
	
}
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:81,代码来源:RegisterView.cpp

示例3: init

// on "init" you need to initialize your instance
bool GameWin::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
   
    Size visiableSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
	

	AppDelegate *app = (AppDelegate*)Application::getInstance();
	  std::string sCSD=app->GetLayoutString();
	 _rootNode = CSLoader::createNode("res/game_passed/GamePassLayer"+sCSD+".csb");

	 //loginLayer=Layer::create();
	 addChild(_rootNode,1);

	 /*
	LayerColor *layer1 = LayerColor::create(Color4B(0, 0, 0, 180));
	TurntableSystem* price =new TurntableSystem(layer1);
	layer1->setTag(CHILD_TURNTABLE);
	addChild(layer1,99);*/
	

	/*
	cocostudio::ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Animation0.png", "Animation0.plist", "Animation.ExportJson");
	cocostudio::Armature *armature = cocostudio::Armature::create("Animation");
	armature->getAnimation()->playByIndex(0);
	armature->setScale(0.5f);
	armature->setPosition(ccp(visibleSize.width * 0.5, visibleSize.height * 0.5));
	this->addChild(armature);
	
	*/

	 /*
	cocostudio::Armature* armature;
	cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("res/animations/coin/coin.ExportJson");
	armature = cocostudio::Armature::create("coin");
	if (armature){
		armature->setPosition(ccp(visiableSize.width * 0.8, visiableSize.height * 0.5));
		armature->getAnimation()->playByIndex(0);
		armature->setScale(0.25);
		this->addChild(armature);
	}
	*/
	


	//Get Promotion 
	// Setting HTTP Request Header
 //   if(m_iIsLoad==0){
 //       m_iIsLoad=1;
	//HttpRequest* request = new HttpRequest();
 //   request->setUrl(PromotionWebGetURL);
 //   request->setRequestType(HttpRequest::Type::GET);
 //   request->setResponseCallback(CC_CALLBACK_2(GameWin::onHttpRequestCompleted,this));
 //   request->setTag("GET test");
 //   cocos2d::network::HttpClient::getInstance()->send(request);
 //   request->release();
 //   }

	//ImageView* imgPromotion = dynamic_cast<ImageView*>(_rootNode->getChildByName("ivPromotionImg")); 
	//	 auto card1 = Sprite::create("match_game_img_1_b.jpg");
	// //card1->setPosition(Vec2(0, imgPromotion->getPositionY()+ imgPromotion->getContentSize().height/2));
	//	log("1=%f,%f,%f,%f",imgPromotion->getPositionX(),imgPromotion->getPositionY(),imgPromotion->getContentSize().width,imgPromotion->getContentSize().height);
	//	card1->setAnchorPoint(Vec2(0,0)); 
	//card1->setPosition(Vec2(0, 0));
	// //float zoom_x = visiableSize.width *0.5 / card1->getContentSize().width;
	//// float zoom_y = visiableSize.height * 0.5 / card1->getContentSize().height;
	// //card1->setScale(0.055f);
	// //card1->setScaleY(zoom_y);
	//card1->setScale(0.38f);
	//  imgPromotion->addChild(card1,2,1001);

	m_PrmtPrdct = app->getPromoteProduct();

	if(m_PrmtPrdct.m_iIsLoad == 0){
        
		m_PrmtPrdct.m_iIsLoad=1;
		HttpRequest* request = new HttpRequest();
		request->setUrl(PromotionWebGetURL);
		request->setRequestType(HttpRequest::Type::GET);
		request->setResponseCallback(CC_CALLBACK_2(GameWin::onHttpRequestCompleted,this));
		request->setTag("GET test");
		cocos2d::network::HttpClient::getInstance()->send(request);
		request->release();
    }

	if(_rootNode){
        auto img=_rootNode->getChildByName("ivPromotionImg");
        if(img){
            ImageView* imgPromotion = dynamic_cast<ImageView*>(_rootNode->getChildByName("ivPromotionImg"));
			auto card1 = Sprite::create(m_PrmtPrdct.m_strImage.c_str());
			card1->setAnchorPoint(Vec2(0,0)); 
			card1->setPosition(Vec2(0, 0));
			card1->setScale((imgPromotion->getBoundingBox().size.width / card1->getContentSize().width));
//.........这里部分代码省略.........
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:101,代码来源:GameWinScene.cpp


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