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


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

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


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

示例1: syncFlow

void GameWin::syncFlow()
{
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	std::string  strFlow= updateFlow();//read local and add current

	NetworkType Networ = app->GetNetWorkStatus();
	if (Networ != NetworkTypeNone)
	{
		if (m_UserID > 0 && strFlow.length()>0)
		{
			_UserInfo userInfo = DataAccess::getUserInfoByID(m_UserID);
			HttpRequest* request = new HttpRequest();
			request->setUrl(UCAPIWebPostURL);
			request->setRequestType(HttpRequest::Type::POST);
			request->setResponseCallback(CC_CALLBACK_2(GameWin::onSyncCompleted, this));

			//char p[10];
			//sprintf(p, "%s", strFlow);
			std::string sPost = "action=save_user_info&EncryptData=";

			long lUserDiff = app->GetUserScoreDiff();
			int iLevel = app->GetUserLevel();


			char p1[10];
			char p2[10];
			char p3[10];
			sprintf(p1, "%d", lUserDiff);
			sprintf(p2, "%d", iLevel);
			string s1 = p1;
			string s2 = p2;

			//std::string sPost = "action=sync_point&EncryptData=";
			int iTools = app->GetToolsDiff();
			sprintf(p3, "%d", iTools);
			string s4 = p3;

			string s3 = "score = " + strFlow + "&local_point = " + s1 + "&LV = " + s2 + "&UserID = " + userInfo.strUserGuid+"&VirtualPops=" + s4;
			s3 = app->encode_data_for_http(s3);
			sPost = sPost + s3;
			sPost = sPost + "&" + app->GetAccessString();

			const char* postData = sPost.c_str();
			request->setRequestData(postData, strlen(postData));
			request->setTag("save_ranking");
			cocos2d::network::HttpClient::getInstance()->send(request);
			request->release();
		}
		else updateLocalFlow();//not login or read local error
	}
	else
	{
		updateLocalFlow();//no network
	}
}
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:55,代码来源:GameWinScene.cpp

示例2: init

bool MultiPriceMatch::init(){

	bool bRet = false;
	do{
		if(!Layer::init()){
			break;
		}

		int currenlevel = 0;

		//if (_gamestatus != GAME_START) {
		//	_gamestatus = GAME_START;
		//}
		AppDelegate *app = (AppDelegate*)Application::getInstance();
		CC_BREAK_IF(!app);

		_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();
		currenlevel = app->getCurrentGameLevel();

		_gametime = GAME_TIME_EASY;

		//_zoomin = true;
		//saveProductInfo();
		CC_BREAK_IF(!loadProductInfo());

		_SORT_UINode = CSLoader::createNode(SORT_UINODE_CSB);
		CC_BREAK_IF(_SORT_UINode == nullptr);
		_SORT_UINode->setTag(SORT_UI_NODE);
		this->addChild(_SORT_UINode);

		_vec_Price.clear();
		_vec_Price_original.clear();
		_vec_Price_index.clear();

		char strName[20] = LBL_SP_PDX;
		char strLabel[20] = IMG_PD_PRICE;
		char strBtn[20] = BTN_PD_PRICE;

		//string price, price2;

		_vec_lblPrice.clear();
		_vec_btnPrice.clear();

		std::vector <std::string> vec_price;
		std::vector <std::string> vec_Price_original;

		std::random_device rd1;
		std::mt19937 g1(rd1());
 		std::shuffle(std::begin(_product_list), std::end(_product_list), g1);


		for (int i = 0; i < 3; i++){
			std::string price = StringUtils::format("%s",_product_list[i].price.c_str());
			//log("Before: price for %d is %s",i, price.c_str());
			vec_price.push_back(price);
			vec_Price_original.push_back(price);
		}
	
		//srand(unsigned(time(NULL)));
		//std::random_shuffle(vec_price.begin(), vec_price.end());


		std::random_device rd;
		std::mt19937 g(rd());
 		std::shuffle(std::begin(vec_price), std::end(vec_price), g);

		//auto engine = std::default_random_engine();
		//std::shuffle(std::begin(vec_price), std::end(vec_price), engine);

		//for (int i = 0; i < 3; i++){
		//	log("After: price for %d is %s",i, vec_price[i].c_str());
		//}

		for (int i = 0; i < 3; i++){
			for (int j = 0; j < 3; j++){
				if (vec_Price_original[i].compare(vec_price[j].c_str()) == 0){
					_vec_Price_index.push_back(j);
				}
			}
		}

		for (int i = 0; i < 3; i++){
			log("%d", _vec_Price_index[i]);
		}

		for (int i = 0; i < 3; i++){
			log("for %d", i);
			strName[5] = LETTER_NUM_1 + i;
			strLabel[6] = LETTER_NUM_1 + i;
			strBtn[6] = LETTER_NUM_1 + i;
			//std::string price = StringUtils::format("%s",_product_list[i].price->getCString());

			//add Image
			auto sp = dynamic_cast<Sprite*>(_SORT_UINode->getChildByName(strName));
			CC_BREAK_IF(sp == nullptr);
			sp->setTag(PRODUCT_IMG_1 + i);
//.........这里部分代码省略.........
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:101,代码来源:MultiPriceMatch.cpp

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


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