예제 #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
// 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;
	
}
예제 #3
0
// 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));
			imgPromotion->addChild(card1,2,1001);
        }
    }
    if(_rootNode && _rootNode->getChildByName("lblProductName")){
        Text* lblProductName=dynamic_cast<Text*>(_rootNode->getChildByName("lblProductName"));// (CCLabelTTF*)this->getChildByTag(2001);
        lblProductName->setString(m_PrmtPrdct.m_strProductName);
    }


	auto btnContine = dynamic_cast<Button*>(_rootNode->getChildByName("btnContine"));
	btnContine->setTag(1001);
	btnContine->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));	

	auto btnQuit = dynamic_cast<Button*>(_rootNode->getChildByName("btnQuit"));
	btnQuit->setTag(1002);
	btnQuit->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));	

	auto btnBuyNow = dynamic_cast<Button*>(_rootNode->getChildByName("btnBuyNow"));
	btnBuyNow->setTag(1003);
	btnBuyNow->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));	

	auto btnShare = dynamic_cast<Button*>(_rootNode->getChildByName("btnShare"));
	btnShare->setTag(1004);
	btnShare->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));	


	//Show Total User Score
	long l_coins = app->GetUserTotalScore();
	char p[20];
	sprintf(p, "%ld", l_coins);
	string sTotal = p;
	
	iReward = app->getReward();
	iStar = app->getStar();
	char p1[20];
	sprintf(p1, "%ld", iReward);
	string sReward = p1;
	app->setReward(0,0);

	auto lblReward = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblReward"));
	if (lblReward)
	{
		lblReward->setString(sReward);
	}
	auto lblScore = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblScore"));
	if (lblReward)
	{
		lblScore->setString(sTotal);
	}


	//_rootNode->getChildByName("Img_Box")->setVisible(false);
	auto imgStar = dynamic_cast<ImageView*>(_rootNode->getChildByName(WIN_STAR_FRAME));	
	if (imgStar != nullptr) {
		_rootNode->getChildByName(WIN_STAR_BOX)->setVisible(false);
		if (iStar == 3){
			imgStar->loadTexture(WIN_STAR_3);
		}
		else if (iStar == 2){
			imgStar->loadTexture(WIN_STAR_2);
		}
		else if (iStar == 1){
			imgStar->loadTexture(WIN_STAR_1);
		}
	}
	if (app->getBGMstatus() == BGMusic_flag::ON)
	{
		app->PlayEffect(SOUND_WIN);
	}


		// start ansyc method load the atlas.png
	//Director::getInstance()->getTextureCache()->addImageAsync("MatchBg.png", CC_CALLBACK_1(GameWin::loadingCallBack, this));
	
	/*auto card1 = Sprite::create("match_game_img_1_b.jpg");
	// card1->setPosition(Vec2(visiableSize.width / 2 +88 * generalscalefactor,   visiableSize.height/2 +50 *generalscalefactor));
	 //float zoom_x = visiableSize.width *0.5 / card1->getContentSize().width;
	// float zoom_y = visiableSize.height * 0.5 / card1->getContentSize().height;
	 card1->setScale(150/800);
	 //card1->setScaleY(zoom_y);
	 
	 Image* image = new Image();
	 image->s
	 Texture2D* texture = new Texture2D();
    
	Sprite* sprite = dynamic_cast<Sprite*>(_rootNode->getChildByName("spPromotionImg"));  //spPromotionImg
	sprite->initWithFile("match_game_img_1_b.jpg");

	  this->addChild(card1,1,1001);
	*/


	Sprite* imgBackground = Sprite::create(WIN_BACKGROUND);

	imgBackground->setAnchorPoint(Vec2(0, 0));
	imgBackground->setPosition(Vec2(0, 0));
	this->addChild(imgBackground, -1, 222); 


	syncFlow();//sync with server
	app->PlayEffect(SOUND_GAME_PASS);

    return true;
}