예제 #1
0
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)]);

		auto memory_bg_2 = dynamic_cast<Sprite*>(_rootNode->getChildByName("memory_bg_2"));
		if (memory_bg_2){
			memory_bg_2->setZOrder(-100);

		}

		//-----------------------------------------Touch Event Create----------------------------------------------------
		auto touchListener1 = EventListenerTouchOneByOne::create();
		touchListener1->onTouchBegan = [this](Touch* touch, Event* event) -> bool//start lambda,[]内为捕获列表
		{
			auto bounds = event->getCurrentTarget()->getBoundingBox();

			if (bounds.containsPoint(touch->getLocation()))
			{
				if (iWaiting == 1){
					return true;
				}
				else if (iWaiting == 2)/*already open 2 cards,turn over,reset*/
				{
					firstCard->setScale(1);
					firstCard->setTexture("res/memory_game/memory_square.png");
					//firstCard->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("memory_square.png"));//roll back 
					firstCard->cancel_rollback_timer();
					secondCard->setScale(1);
					secondCard->setTexture("res/memory_game/memory_square.png");
					//secondCard->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("memory_square.png"));//roll back
					secondCard->cancel_rollback_timer();
					iFirstCard = -1;
					iSecondCard = -1;
					iWaiting = 0;
					return true;
				}

				auto target = static_cast<TouchSprite*>(event->getCurrentTarget());
				int i = target->getTag() - 1000;
				char file[100];
				if (i<1 || i>8){
					log("invalide target tag=%d", i);
					return true;
				}
				sprintf(file, "%s", sFile[i - 1]);

				bool bFound = false;
				log("enter here 1=%d,2=%d", iFirstCard, iSecondCard);
				if (iFirstCard == -1 && iSecondCard == -1)
				{
					iFirstCard = target->getZOrder() - 20;
				}
				else if (iFirstCard >= 0 && iSecondCard == -1)
				{
					iWaiting = 1; //waiting for 
					iSecondCard = target->getZOrder() - 20;
					if (iFirstCard == iSecondCard)
					{
						//The same card,
						bFound = false;
						iSecondCard = -1;
						iWaiting = 0;
						return 0;
					}
					else
					{
						firstCard = (TouchSprite*)spCard.at(iFirstCard);
						secondCard = (TouchSprite*)spCard.at(iSecondCard);
						log("tag1=%d,tag2=%d", firstCard->getTag(), secondCard->getTag());
						if (firstCard->getTag() == secondCard->getTag() && firstCard->getTag()>1000)
						{
							bFound = true;
							firstCard->setTag(999);
							secondCard->setTag(999);
							iFirstCard = -1;
							iSecondCard = -1;
							iWaiting = 0;
							CheckWin();
						}
						else
						{
							iFirstCard = -1;
							iSecondCard = -1;
							log("not found!");
							iWaiting = 2;//next touch will reset
							if (iTotalTime > 1)
							{
								iTotalTime --;
							}
							else
							{
								iTotalTime = 0;
							}
							this->showDeductPointEffect("lblTimer");
						}
					}
				}
				if (!bFound)
				{
					log("file=%s,should setup rollback timer,tag=%d", file, target->getTag());
					target->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));
					if (!target)
					{
						return 1;
					}
					//target->setScale(0.95);//?
					target->setScaleX(0.9);
					target->setScaleY(0.97);

					if (iFirstCard >= 0 && iSecondCard == -1)//first card
					{
						firstCard = target;
						target->setup_rollback_timer(4);//scheduleOnce(schedule_selector(GameLayer::RollBackClickMe), 2.0f );
					}
					else
					{
						iFirstCard = -1;
						iSecondCard = -1;
						firstCard->cancel_rollback_timer();
						firstCard->setup_rollback_timer(2);//should be rollback with the first card simultaneously
						target->setup_rollback_timer(2);//should be rollback with the first card simultaneously
					}
				}
				else//bFound==true
				{
					log("found 1=%d,2=%d", iFirstCard, iSecondCard);
					//reset it
					firstCard->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));
					//firstCard->setScale(0.95);
					firstCard->setScaleX(0.9);
					firstCard->setScaleY(0.97);
					secondCard->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));
					//secondCard->setScale(0.95);
					secondCard->setScaleX(0.9);
					secondCard->setScaleY(0.97);
					log("found it tag=%d,tag2=%d", firstCard->getTag(), secondCard->getTag());

				}
				//delete[]file;
			}
			return true;
		};

		for (int col = 0; col < iCols; col++)
		{
			float x_position = 0.0;
			if (col <= iCols / 2)
			{
				x_position = Director::getInstance()->getVisibleSize().width / 2 - (iCols / 2 - col) * 190 + 80;
			}
			else
			{
				x_position = Director::getInstance()->getVisibleSize().width / 2 + (col - iCols / 2) * 190 + 80;
			}
			for (int row = 0; row < iRows; row++)
			{
				float y_position = 0.0;
				if (row <= iRows / 2)
				{
					y_position = Director::getInstance()->getVisibleSize().height / 2 + (iRows / 2 - row) * 190 - 80;
				}
				else
				{
					y_position = Director::getInstance()->getVisibleSize().height / 2 - (row - iRows / 2) * 190 - 80;
				}
				auto card1 = Sprite::create("res/memory_game/memory_square.png");

				/*
				char file[100];
				sprintf(file, "%s", sFile[0]);
				card1->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));*/
				card1->setPosition(Vec2(x_position + 50, y_position));

				if (row == 0 && col == 0){
					Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener1, card1);
				}
				else{
					Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener1->clone(), card1);
				}
				int index = row + col*iRows;
				this->addChild(card1, 20 + index, 1001 + unique_array[index]);
				log("index=%d,z-index=%d,x=%f,y=%f", index, unique_array[index], x_position, y_position);
				spCard.pushBack(card1);

				auto card2 = Sprite::create("res/memory_game/kuang.png");
				card2->setPosition(Vec2(x_position + 50, y_position));
				this->addChild(card2, 100 + index, 1001 + unique_array[index]);
				log("index=%d,z-index=%d,x=%f,y=%f", index, unique_array[index], x_position, y_position);

			}
		}

		iFirstCard = -1;
		iSecondCard = -1;

		app->LogAccess("MemoryMatch");
		m_iCurrentGameLevel = app->getCurrentGameLevel();

		schedule(schedule_selector(GameLayer::updateLabels), 0.01f);
		schedule(schedule_selector(GameLayer::updateTimeLabel), 1.0f);

		delete[] array1;
		delete[] array2;
		delete[] unique_array;
		delete[] array4;
		//Director::sharedDirector()->getScheduler()->scheduleSelector(SEL_SCHEDULE(&GameLayer::loadingCallBack), this, .5f, false);


		//-----------------------------------add animation----------------------------------------------------------

		auto mastco = dynamic_cast<Sprite *> (_rootNode->getChildByName("Sprite_10"));
		//int mastcoZOrder=-1;
		if (mastco)
		{
			//mastcoZOrder = mastco->getZOrder();
			mastco->setVisible(false);
		}

		ArmatureDataManager::getInstance()->addArmatureFileInfo("res/animations/1.3/1.3.ExportJson");
		Armature *armature = Armature::create("1.3");
		armature->setAnchorPoint(Vec2(0.5, 0.5));
		armature->setRotation(270);
		armature -> setPosition(Vec2(150,400));
		armature->setVisible(true);
		armature->setTag(888);
		schedule(schedule_selector(GameLayer::PlayAnimation), 5.0f);
		_rootNode->addChild(armature);
		nAniFlag = 1;
		//-------------------------------------------------------------------------------------

		_bTlEnabled = true;

		return true;
	}
	else
	{
		return false;
	}
}
예제 #2
0
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);
			//sp->setTexture(_product_list[i].image->getCString());
			sp->setTexture(_product_list[i].image.c_str());
			sp->setScale((sp->getBoundingBox().size.width/sp->getContentSize().width)*0.6);//resize to 300 
			sp->setZOrder(2);

			//sp->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnPriceCallback, this));



			//add Price Label
			auto label = dynamic_cast<Sprite*>(_SORT_UINode->getChildByName(strLabel));
			CC_BREAK_IF(label == nullptr);
			label->setTag(LBL_PRICE_1 + i);
			label->setZOrder(0);
			_vec_lblPrice.push_back(label);
			//_vec_originalPos.push_back(label->getPosition());

			//add Price Button
			auto btn = dynamic_cast<Button*>(_SORT_UINode->getChildByName(strBtn));
			CC_BREAK_IF(btn == nullptr);
			btn->setTag(BTN_PRICE_1 + i);
			btn->setTitleText(vec_price[i]);
			btn->setTitleColor(ccc3(255,248,220));
			btn->setTitleFontSize(32);
			btn->setZOrder(1);
			btn->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnPriceCallback, this));
			_vec_originalPos.push_back(btn->getPosition());
			_vec_btnPrice.push_back(btn);

		}

		auto lblTimer = dynamic_cast<Text*>(_SORT_UINode->getChildByName(TXT_TIMER));
		CC_BREAK_IF(lblTimer == nullptr);
		this->schedule(schedule_selector(MultiPriceMatch::updateTimeLabel), 0.01f);

		auto btnMain = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BUTTON_MAIN));
		CC_BREAK_IF(btnMain == nullptr);
		//auto btnSetting = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BUTTON_SETTING));
		//auto btnVoice = dynamic_cast<Button*>(_SORT_UINode->getChildByName("btnVoice"));
		auto btnQuit = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BUTTON_QUIT));
		CC_BREAK_IF(btnQuit == nullptr);

		if (app->iGameMode == MobileGameMode::Theme_Mode){
			//btnMain->setVisible(false);
			//btnQuit->setVisible(false);
		}
		//auto btMagnifier = dynamic_cast<Button*>(_SORT_UINode->getChildByName("btMagnifier"));
		//Add by Long for theme mode

		//Add by Long EOF

		//test button
		btnMain->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::menuKeyCallback, this));
		btnQuit->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::ShowTutorialCallback, this));


		auto btnClr = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BTN_CLEAR));
		CC_BREAK_IF(btnClr == nullptr);
		btnClr->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnClear, this));
		btnClr->setTitleColor(ccc3(255,248,220));
		btnClr->setTitleFontSize(32);
		btnClr->setTitleText("CLEAR");
		btnClr->setVisible(false);

		auto txtClear = dynamic_cast<Text*>(_SORT_UINode->getChildByName("clear"));
		txtClear->setVisible(false);
		//btnClr->addChild(txtClear);

		auto btnSub = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BTN_SUBMIT));
		CC_BREAK_IF(btnSub == nullptr);
		btnSub->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnSubmit, this));
		btnSub->setTitleColor(ccc3(255,248,220));
		btnSub->setTitleFontSize(32);
		btnSub->setTitleText("SUBMIT");
		btnSub->setVisible(false);

		auto txtsubmit = dynamic_cast<Text*>(_SORT_UINode->getChildByName("submit"));
		txtsubmit->setVisible(false);

		auto txtPrice1 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_1"));
		auto txtPrice2 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_2"));
		auto txtPrice3 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_3"));
		txtPrice1->setVisible(false);
		txtPrice2->setVisible(false);
		txtPrice3->setVisible(false);

		auto lvlbar = dynamic_cast<Sprite*> (_SORT_UINode->getChildByName(LINK_UI_LEVELBAR));
		lvlbar->setAnchorPoint(Vec2(0,0.5));
		//lvlbar->setPositionX(lvlbar->getPositionX()-lvlbar->getContentSize().width/2);
		lvlbar->setScaleX(_fPerToNLvl);

		auto btnTips = dynamic_cast<Button*>(_SORT_UINode->getChildByName(LINK_UI_BTN_TIPS));
		CC_BREAK_IF(btnTips == nullptr);
		btnTips->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::ShowHintCallback, this));


		auto touchListener = EventListenerTouchOneByOne::create();
		touchListener->onTouchBegan = CC_CALLBACK_2(MultiPriceMatch::onTouchBegan, this);
		touchListener->onTouchEnded = CC_CALLBACK_2(MultiPriceMatch::onTouchEnded, this);
		touchListener->onTouchMoved = CC_CALLBACK_2(MultiPriceMatch::onTouchMoved, this);
		touchListener->onTouchCancelled = CC_CALLBACK_2(MultiPriceMatch::onTouchCancelled, this);
		_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);

		//AppDelegate *app = (AppDelegate*)Application::getInstance();
		if (app->iGameMode == MobileGameMode::Theme_Mode){
			btnMain->setVisible(false);
			//btnSetting->setVisible(false);
			//btnVoice->setVisible(false);
			btnQuit->setVisible(false);
		}

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

		//UserDefault *load = UserDefault::getInstance();
		//string sFirstFlip = load->getStringForKey("FIRSTTIME_LINK","0");
		//{
		//	if (atoi(sFirstFlip.c_str()) == 0)
		//	{
		//		scheduleOnce(schedule_selector(MultiPriceMatch::loadFirstTutorial), 1.1f);
		//		load->setStringForKey("FIRSTTIME_LINK", "1");
		//	}
		//}
		_bTlEnabled = true;

		//-----------------------------------add animation----------------------------------------------------------

		ArmatureDataManager::getInstance()->addArmatureFileInfo(ANIMATION_FILE);
		Armature *armature = Armature::create(ARMATURE);
		CC_BREAK_IF(armature == nullptr);
		armature->setAnchorPoint(Vec2(0.5, 0.5));
		armature->setVisible(true);
		armature->setPosition(Vec2(235, 480));
		armature->setTag(888);
		auto imgBackFrame = dynamic_cast<Sprite*> (_SORT_UINode->getChildByName(BOARD));
		CC_BREAK_IF(imgBackFrame == nullptr);
		imgBackFrame->setZOrder(1);
		schedule(schedule_selector(MultiPriceMatch::PlayAnimation), 5.0f);
		_SORT_UINode->addChild(armature);


		//-------------------------------------------------------------------------------------
		bRet = true;
	}while(0);

	return bRet;
}
예제 #3
0
// on "init" you need to initialize your instance
bool CollageScene::init()
{
    
	
	string filePath = FileUtils::getInstance()->getWritablePath();
	TEMP_filePath = filePath;
	filePath += Cache_Path;
	if(access(filePath.c_str(),0)<0)
	{
		if(!CreateFolder(filePath.c_str()))
		{
			MessageBox("Can not create Cache Folder","Device ERROR");
			return false;
		}
	}
	//////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
	auto loadingUI = CSLoader::createNode("Collage/LoadingScene.csb");
	addChild(loadingUI);

	textPercentage = dynamic_cast<Text*>(loadingUI->getChildByName("Text_Percentage"));
	textPercentage->setText("0%");
	auto Image_bar = Sprite::create("Collage/bar.png");
	
	ct= ProgressTimer::create(Image_bar);
	ct->setAnchorPoint(Vec2::ZERO);
	ct->setPosition(Vec2(319,317));
	
	ct->setType(ProgressTimer::Type::BAR);
	ct->setMidpoint(Vec2(0,0));
	ct->setBarChangeRate(Vec2(1,0));
	ct->setPercentage(0);
	addChild(ct);

	std::thread t1(&CollageScene::LoadResources,this);
	t1.detach();

	Director::sharedDirector()->getScheduler()->scheduleSelector(SEL_SCHEDULE(&CollageScene::loadingCallBack), this, .5f, false);

	////////////////////////////////loading coloar pattern//////////
	sctColorList ColorPattern;
	
	ColorPattern.R=255;
	ColorPattern.G=255;
	ColorPattern.B=255;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=255;
	ColorPattern.G=245;
	ColorPattern.B=114;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=255;
	ColorPattern.G=206;
	ColorPattern.B=81;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=247;
	ColorPattern.G=147;
	ColorPattern.B=78;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=240;
	ColorPattern.G=83;
	ColorPattern.B=63;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=226;
	ColorPattern.G=0;
	ColorPattern.B=137;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=158;
	ColorPattern.G=61;
	ColorPattern.B=150;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=182;
	ColorPattern.G=189;
	ColorPattern.B=224;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=0;
	ColorPattern.G=181;
	ColorPattern.B=239;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=0;
	ColorPattern.G=108;
	ColorPattern.B=163;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=210;
	ColorPattern.G=235;
	ColorPattern.B=226;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=109;
	ColorPattern.G=196;
	ColorPattern.B=188;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=88;
	ColorPattern.G=185;
	ColorPattern.B=71;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=0;
	ColorPattern.G=115;
	ColorPattern.B=102;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=224;
	ColorPattern.G=193;
	ColorPattern.B=169;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=190;
	ColorPattern.G=135;
	ColorPattern.B=105;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=142;
	ColorPattern.G=83;
	ColorPattern.B=42;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=223;
	ColorPattern.G=225;
	ColorPattern.B=223;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=121;
	ColorPattern.G=125;
	ColorPattern.B=130;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=52;
	ColorPattern.G=55;
	ColorPattern.B=65;
	HttpConnection::v_color_list.push_back(ColorPattern);

	ColorPattern.R=0;
	ColorPattern.G=0;
	ColorPattern.B=0;
	HttpConnection::v_color_list.push_back(ColorPattern);
	HttpConnection::numberOfLoadSprites++;

	AppDelegate *app = (AppDelegate*)Application::getInstance();
	if ( app->getBGMstatus() == BGMusic_flag::ON){
		app->StartBGMusic(BGM_COLLAGE);
	}

	return true;
}