Beispiel #1
0
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
Beispiel #2
0
void MenuLayer::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.", "Alert");
#else
	Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	exit(0);
#endif
#endif
}
Beispiel #3
0
void SetPanel::onClick(CCObject* ob)
{
	CButton* btn = (CButton*)ob;
	int tag = btn->getTag();
	switch(tag)
	{
	case 1:
		{
			if(this->getParent())
				this->getParent()->removeChild(this);
		}
		break;
	case 2:
		{
			CNetClient::getShareInstance()->sendDataType(RoleExitMsg);
			//CSceneManager::sharedSceneManager()->getScene("CityScene")->release();
			CCDirector::sharedDirector()->replaceScene(GETSCENE(LoginScene));
		}
		break;
	case 3:
		{
			CNetClient::getShareInstance()->sendDataType(RoleExitMsg);
			CCDirector::sharedDirector()->end();
		}
		break;
	case 4:
		{
			CCMessageBox(GETLANGSTR(1012), GETLANGSTR(1005));
			//ShowTexttip(U8("此功能尚未开放,敬请期待"),RGB_RED);
		}
		break;
	case 5:
		{
			CCMessageBox(GETLANGSTR(1012), GETLANGSTR(1005));
			//ShowTexttip(U8("此功能尚未开放,敬请期待"),RGB_RED);
		}
		break;
	default:
		break;
	}
}
void BeginScene::fbSessionCallback(int responseCode, const char *responseMessage)
{
    
    if (responseCode != EziSocialWrapperNS::RESPONSE_CODE::FB_LOGIN_SUCCESSFUL)
    {
        CCMessageBox(responseMessage, "Facebook Login");
    }
    else
    {
        CCLOG("Login Success!!!");
    }
}
Beispiel #5
0
void CMainMenuLayer::settingCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCScene* newScene = CSettingScene::create();
	CCDirector::sharedDirector()->pushScene( newScene );
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //exit(0);
#endif
#endif
}
Beispiel #6
0
bool CLevelManager::CreateFileFirstGame( const char* pc_FileName, int iNumOfLevel )
{

	bool result = true;
	
	string pathTest = CCFileUtils::sharedFileUtils()->getWriteablePath();
	
#if ANDROID
	char FullPath[256] = {0};
	strcpy(FullPath,pathTest.c_str());
	strcat(FullPath,"LevelInfo.txt");
	FILE* pFile;
	pFile = fopen(FullPath,"r");
	if (pFile != NULL)
	{
		result = false;
		
		fclose(pFile);
	}
	else
	{
		result = true;
		
		pFile = fopen(FullPath,"w+");
		
		if (pFile != NULL)
		{
			fprintf(pFile,"%d\n",iNumOfLevel);
			for (int i = 0; i < iNumOfLevel; i ++)
			{
				if (i <= 5) 
				{
					fprintf(pFile,"%d 0 0 1\n", (i+1) );
				}
				else
				{
					fprintf(pFile,"%d 0 0 0\n", (i+1) );
				}
			}

			fclose(pFile);
			//ResetLevelInfo(iNumOfLevel);
			return true;
		}
		else
		{
			CCMessageBox("Create first file failed","Error");
		}
	}
	
#endif
	return result;
}
void CResultTitleLayer::mainSceneCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	CCScene* newScene = CMainScene::create();
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5, newScene) );
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
Beispiel #8
0
void BaseScene::fbIncomingRequestCallback(int responseCode, const char* responseMessage, int totalIncomingRequests)
{
    if (totalIncomingRequests > 0)
    {
        int pendingRequest = EziFBIncomingRequestManager::sharedManager()->getPendingRequestCount();
        CCString* message = CCString::createWithFormat("Total new requests = %d\n Total pending requests = %d.\nGo to Request API Scene to see the list of incoming requets.", totalIncomingRequests, pendingRequest);
        CCMessageBox(message->getCString(), "fbIncomingRequestCallback");
    }
    else
    {
        CCLOG("No new incoming request...");
    }
}
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{	
	string fullPath = s_strRelativePath + pszFileName;
	unsigned char * pData =  CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize);
    if (! pData && getIsPopupNotify())
    {
        std::string title = "Notification";
        std::string msg = "Get data from file(";
        msg.append(pszFileName).append(") failed!");
        CCMessageBox(msg.c_str(), title.c_str());
    }
    return pData;
}
Beispiel #10
0
void GameOverView::onYesClicked()
{
    CCLOG("Yes!");
    CCLOG("Quit the game!");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
void MoreDiamondDialog::onGetProfileCompleted( CCNode *sender, void *data )
{
	CCLOG("onGetProfileCompleted");
	if (data != NULL)
	{
		CCDictionary *convertedData = (CCDictionary *)data;
		CCString* s = (CCString*)convertedData->objectForKey("isSuccess");
		if (s->boolValue())
		{
			CCLOG("CPP Get Profile Completed: TRUE");

			string fbId = ((CCString*)convertedData->objectForKey("id"))->getCString();
			string firstName = ((CCString*)convertedData->objectForKey("firstName"))->getCString();
			string name = ((CCString*)convertedData->objectForKey("name"))->getCString();
			string username = ((CCString*)convertedData->objectForKey("username"))->getCString();
			string birthday = ((CCString*)convertedData->objectForKey("birthday"))->getCString();
			string picture50x50 = ((CCString*)convertedData->objectForKey("picture"))->getCString();

			//save

			DataManager::sharedDataManager()->SetFbID(fbId);
			DataManager::sharedDataManager()->SetFbFullName(name);
			DataManager::sharedDataManager()->SetName(name);
			DataManager::sharedDataManager()->SetFbUserName(username);

			//////////////////////////////////////////////////////////////////////////

			NDKHelper::AddSelector("MoreDiamondDialog",
				"onGetAvatarCompleted",
				callfuncND_selector(MoreDiamondDialog::onGetAvatarCompleted),
				this);

			string w = "128";
			string h = "128";

			CCDictionary* prms = CCDictionary::create();
			prms->setObject(CCString::create(fbId), "fbId");
			prms->setObject(CCString::create(w), "width");
			prms->setObject(CCString::create(h), "height");

			SendMessageWithParams(string("GetAvatar"), prms);
		} 
		else
		{
			CCLOG("CPP Get Profile Completed: FALSE");
			CCMessageBox("Không thể kết nối", "Lỗi");
		}

		NDKHelper::RemoveSelector("MoreDiamondDialog", "onGetProfileCompleted");
	}
}
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{	
	unsigned char * buffer = NULL;

	std::string full_path = pszFileName;

	// If it is not inside resource path
	if (full_path.find(s_strResourcePath) == std::string::npos) 
    {
			full_path = s_strResourcePath + pszFileName;
	}

	// if specify the zip file,load from it first
	if (s_pszZipFilePath[0] != 0)
	{
		buffer = getFileDataFromZip(s_pszZipFilePath.c_str(), full_path.c_str(), pSize);
	}

	// if that failed then let's try and load the file ourselves
	if (!buffer)
	{
		// read the file from hardware
		FILE *fp = fopen(full_path.c_str(), pszMode);
		if (fp)
		{
			fseek(fp, 0, SEEK_END);
			*pSize = ftell(fp);
			fseek(fp, 0, SEEK_SET);
			buffer = new unsigned char[*pSize];
			*pSize = fread(buffer, sizeof(unsigned char), *pSize, fp);
			fclose(fp);
		}
	}

	// we couldn't find the file
	if (!buffer && getIsPopupNotify())
	{
		std::string title = "Notification";
		std::string msg = "Get data from file(";
		msg.append(full_path);
		if (s_pszZipFilePath[0] != 0)
		{
			msg.append(") in zip archive(").append(s_pszZipFilePath);
		}
		msg.append(") failed!");

		CCMessageBox(msg.c_str(), title.c_str());
	}

	return buffer;
}
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{	
	unsigned char * pData = 0;
	string fullPath(pszFileName);

	if ((! pszFileName) || (! pszMode))
	{
		return 0;
	}

	if (pszFileName[0] != '/')
	{
		// read from apk
		fullPath.insert(0, "assets/");
		pData =  CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize);
	}
	else
	{
		do 
		{
			// read rrom other path than user set it
			FILE *fp = fopen(pszFileName, pszMode);
			CC_BREAK_IF(!fp);

			unsigned long size;
			fseek(fp,0,SEEK_END);
			size = ftell(fp);
			fseek(fp,0,SEEK_SET);
			pData = new unsigned char[size+1];
            pData[size] = '\0';
			size = fread(pData,sizeof(unsigned char), size,fp);
			fclose(fp);

			if (pSize)
			{
				*pSize = size;
			}			
		} while (0);		
	}

    if (! pData && getIsPopupNotify())
    {
        std::string title = "Notification";
        std::string msg = "Get data from file(";
        msg.append(fullPath.c_str()).append(") failed!");
        CCMessageBox(msg.c_str(), title.c_str());
    }

    return pData;
}
Beispiel #14
0
void CommandManager::onResponse(CCHttpClient* client, CCHttpResponse* response)
{
    const string commandName = m_currentCommand->getName();
    if (response->isSucceed())
    {
        
        
        m_currentCommand->setCommandState(CommandStateResonsedProcessed);
        if (m_currentCommand->getMessageHandler())
        {
            int responseCode = response->getResponseCode();
            
            RawData* responseData = response->getResponseData();
            int responseDataSize = responseData->size();
            
            const char* data = &((*responseData)[0]);
            
            CCLOG("command %s response code %d length %d", commandName.c_str(), responseCode, responseDataSize);
            
            ResponseMessage message;
            bool decoded = message.ParseFromArray(data, responseDataSize);
            
            CCAssert(decoded, FORMAT("command %s decode fail data length=%d", commandName.c_str(), responseDataSize));
            
            m_currentCommand->getMessageHandler()->setMessage(&message);
            m_currentCommand->getMessageHandler()->execute();
            
        }
    }
    else
    {
        CCLOG("command %s fail errorcode=%d error message=%s", commandName.c_str(), response->getResponseCode(), response->getErrorBuffer());
        
        int resendCount = m_currentCommand->getResendCount();
        if (resendCount < MAX_RESEND_COUNT)
        {
            client->send(response->getHttpRequest());
            
            m_currentCommand->setResendCount(resendCount + 1);
            
            CCLOG("resend command %s for the %d time(s)", commandName.c_str(), resendCount);
        }
        else
        {
            CCMessageBox(FORMAT("Command fail %s", commandName.c_str()), "Error");
        }
        
    }
    
}
void CStartAndHelpButtonLayer::ReadyButtonCallBack( CCObject* pSender )
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	// 서버로 레디 신호를 보낸다.
	CGameManager::GetInstance()->StartGame();
	// Scene Change는 GetCurrentScene 을 통해서 비교 / Online 에서는 임의로 Scene을 바꾸지 않는다.
	
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	//exit(0);
#endif
#endif
}
Beispiel #16
0
void FriendList::showAllFriendsList()
{
    if (ALL_DOWNLOAD_COMPLETE == false)
    {
        CCMessageBox("Downloading of images in Progess. Try after sometime", "Downloading Images");
        return;
    }
    else
    {
        ALL_DOWNLOAD_COMPLETE = false;
    }
    this->showLoadingAction();
    this->unscheduleUpdate();
    EziSocialObject::sharedObject()->getFriends(EziSocialWrapperNS::FB_FRIEND_SEARCH::ALL_FRIENDS, 20, 20);
}
void CNetworkPlayerNumberLayer::MainSceneCallback(cocos2d::CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    // 여기서 다음 단계로 넘어가면서 로그인을 하므로 뒤로 가면 로그아웃 할 필요는 없다.
	// CGameManager::GetInstance()->Logout();
    
	CCScene* newScene = CMainScene::create();
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5, newScene) );
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	//exit(0);
#endif
#endif
}
Beispiel #18
0
void CMainMenuLayer::newgameCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
   //newgame load
    CGameManager::GetInstance()->SetOnlineMode(false);
    
	CCScene* newScene = CGameSettingScene::create();
	CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5, newScene) );
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //exit(0);
#endif
#endif
}
Beispiel #19
0
void FriendList::showHighScoreList()
{
    if (ALL_DOWNLOAD_COMPLETE == false)
    {
        CCMessageBox("Downloading of images in Progess. Try after sometime", "Downloading Images");
        return;
    }
    else
    {
        ALL_DOWNLOAD_COMPLETE = false;
    }
    
    this->showLoadingAction();
    this->unscheduleUpdate();
    EziSocialObject::sharedObject()->getHighScores();
}
Beispiel #20
0
void CMainMenuLayer::multiplayCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	CGameManager::GetInstance()->SetOnlineMode(true);
	CGameManager::GetInstance()->InitNetworkLogic();
    CGameManager::GetInstance()->SetConnectionStatus(true);

    CCScene* newScene = CLoginScene::create();
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5, newScene) );
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //exit(0);
#endif
#endif
}
void CNetworkPlayerNumberLayer::NumberOfPlayerCallBack( CCObject* pSender )
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	// ∏Ó ∏Ì¿Ã «√∑π¿Ã«“¡ˆ∏¶ ∞Ò∂˙¥Ÿ∏È ∞™¿ª ¿¸¥fi«‘
	int selectedPlayerNumber = static_cast<CCMenuItem*>(pSender)->getTag();

	// ¡∂Ω…«ÿ! HardCoding^^;
	CGameManager::GetInstance()->SetPlayerNumberOfThisGame(selectedPlayerNumber + 1);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	//exit(0);
#endif
#endif
}
Beispiel #22
0
void LoginScene::sendLoginData()
{
    if(strlen(edtUserName->getText())==0 || strlen(edtPassword->getText())==0)
    {
        CCMessageBox(UiLanguage::shareLanguage()->get("login_check"), UiLanguage::shareLanguage()->get("msgbox_notice"));
        return;
    }
    CSJson::Value root;
    CSJson::FastWriter writer;
    root["username"] = edtUserName->getText();
    root["password"] = edtPassword->getText();
    std:string data = writer.write(root);
    Message* msg = new Message(data.c_str(), 1001);
    socket->sendMessage(msg);
    this->schedule(schedule_selector(LoginScene::recvLoginData));
}
SuperAnimSpriteId SuperAnimSpriteMgr::LoadSuperAnimSprite(std::string theSpriteName)
{
	// already load the sprite ?
	IdToSuperAnimSpriteMap::iterator anItr = mSuperAnimSpriteMap.begin();
	while (anItr != mSuperAnimSpriteMap.end())
	{
		if (anItr->second->mStringId == theSpriteName) {
			return anItr->first;
		}
		anItr++;
	}
	
	std::string anImageFileName;
	std::string anImageFile;
	int aLastSlashIndex = MAX((int)theSpriteName.find_last_of('/'), (int)theSpriteName.find_last_of('\\'));
	if (aLastSlashIndex != std::string::npos) {
		anImageFileName = theSpriteName.substr(aLastSlashIndex + 1);
	} else {
		anImageFileName = theSpriteName;
	}
	
	bool hasFileExt = anImageFileName.find('.') != std::string::npos;
	if (!hasFileExt) {
		// PNG by default if not specified format
		anImageFile = theSpriteName + ".png";
	} else {
		anImageFile = theSpriteName;
	}
	// load the physical sprite
	CCRect aTextureRect;
	CCTexture2D *aTexture = getTexture(anImageFile.c_str(), aTextureRect);
	if (aTexture == NULL) {
		char aBuffer[256];
		sprintf(aBuffer, "%s is missing.", anImageFileName.c_str());
		CCMessageBox(aBuffer, "Error");
		return InvalidSuperAnimSpriteId;
	}
	
	// create new super animation sprite
	SuperAnimSprite *aSuperAnimSprite = new SuperAnimSprite(aTexture, aTextureRect);
	// use the sprite name as the key
	aSuperAnimSprite->mStringId = theSpriteName;
	SuperAnimSpriteId anId = aSuperAnimSprite;
	mSuperAnimSpriteMap[anId] = aSuperAnimSprite;
	
	return anId;
}
Beispiel #24
0
bool CCEGLView::initGL()
{
    m_hDC = GetDC(m_hWnd);
    SetupPixelFormat(m_hDC);
    //SetupPalette();
    m_hRC = wglCreateContext(m_hDC);
    wglMakeCurrent(m_hDC, m_hRC);

    // check OpenGL version at first
    const GLubyte* glVersion = glGetString(GL_VERSION);
    CCLOG("OpenGL version = %s", glVersion);

    if ( atof((const char*)glVersion) < 1.5 )
    {
        char strComplain[256] = {0};
        sprintf(strComplain, 
		"Your OpenGL version is %s, but Cocos2d-x requires OpenGL 1.5 or higher on Windows. Please upgrade the driver of your video card", 
		glVersion);
	CCMessageBox(strComplain, "OpenGL version tooooooooooold");
    }

    GLenum GlewInitResult = glewInit();
    if (GLEW_OK != GlewInitResult) 
    {
        fprintf(stderr,"ERROR: %s\n",glewGetErrorString(GlewInitResult));
        return false;
    }

    if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
    {
        CCLog("Ready for GLSL");
    }
    else 
    {
        CCLog("Not totally ready :(");
    }

    if (glewIsSupported("GL_VERSION_2_0"))
    {
        CCLog("Ready for OpenGL 2.0");
    }
    else
    {
        CCLog("OpenGL 2.0 not supported");
    }
    return true;
}
void CStartAndHelpButtonLayer::StartButtonCallBack( CCObject* pSender )
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	CGameManager::GetInstance()->StartGame();

	if ( !CGameManager::GetInstance()->IsOnlineMode() )
	{
		CCScene* newScene = CPlayScene::create();
		CCDirector::sharedDirector()->replaceScene( CCTransitionFade::create(0.5, newScene) );
	}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	//exit(0);
#endif
#endif
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
	CCArmatureDataManager::purge();
	SceneReader::sharedSceneReader()->purge();
	cocos2d::extension::ActionManager::shareManager()->purge();
	GUIReader::shareReader()->purge();



#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
void CSettingCharacterLayer::SelectCharacterCallBack(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	// 조심해!! 현재 캐릭터 선택 / 취소가 체크박스 로직이 아니라 클릭했다 손을 떼면 취소되는 형태
	// 적당한 API가 있을 것 같은데.. 좀 더 뒤져봐야겠다.
	// 해결책 : 오버라이딩으로 새 클래스 구현하면 된답니다.
	// 어떤 버튼이 클릭되었는지를 알아본다.
	int selectedCharacterId = static_cast<CCMenuItem*>(pSender)->getTag();

	CGameManager::GetInstance()->SelectCharacter(selectedCharacterId);
	
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	exit(0);
#endif
#endif
}
void SoloGameScene::initRandomLevel(int number)
{
	m_curQuest = LevelManager::shareLevelLoader()->getLevelInRandom(number);
	
	if (m_curQuest != NULL)
	{
		m_lbQuestion->setString(m_curQuest->m_quest.c_str());
		m_curRightAnswer = m_curQuest->m_right; //0 -> 3
		
		m_lbAnswers[0]->setString(string("A. ").append(m_curQuest->m_arrChoice[0].c_str()).c_str());
		m_lbAnswers[1]->setString(string("B. ").append(m_curQuest->m_arrChoice[1].c_str()).c_str());
		m_lbAnswers[2]->setString(string("C. ").append(m_curQuest->m_arrChoice[2].c_str()).c_str());
		m_lbAnswers[3]->setString(string("D. ").append(m_curQuest->m_arrChoice[3].c_str()).c_str());
	} 
	else
	{
		CCMessageBox("Bạn đã hoàn thành game!", "Chúc mừng");
	}
}
void HelloWorld::keyBackClicked() {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
	PopupLayer* pl = PopupLayer::create("pop_bg.png");
	// ContentSize 是可选的设置,可以不设置,如果设置把它当作 9 图缩放
	pl->setContentSize(CCSizeMake(400, 300));
	pl->setTitle("确认");
	pl->setContentText("要离开游戏吗?", 28, 60, 250);
	// 设置回调函数,回调传回一个 CCNode 以获取 tag 判断点击的按钮
	// 这只是作为一种封装实现,如果使用 delegate 那就能够更灵活的控制参数了
	pl->setCallbackFunc(this, callfuncN_selector(HelloWorld::popupCallback));
	// 添加按钮,设置图片,文字,tag 信息
	pl->addButton("pop_button.png", "pop_button.png", "退出", 0);
	pl->addButton("pop_button.png", "pop_button.png", "取消", 1);
	// 添加到当前层
	this->addChild(pl, 5);
#endif
}
void SoloGameScene::itHelp1Callback( CCObject* pSender )
{
	int diamond = DataManager::sharedDataManager()->GetDiamond();
	int diamond_for_exclusive = DataManager::sharedDataManager()->GetDiamondForExclusive();
	if (diamond < diamond_for_exclusive)
	{
		PLAY_OUT_PORP_EFFECT;
		m_lbDiamond->runAction(CCSequence::createWithTwoActions(
			CCScaleTo::create(0.2f, 1.5f),
			CCScaleTo::create(0.2f, 1.0f)
			));
		return;
	}
	
	if (m_curDisableChoose >= 2)
	{
		PLAY_OUT_PORP_EFFECT;
		CCMessageBox("Chỉ được bỏ tối đa 2 câu!", "Thông tin");
		return;
	}
	

	bool isOK = false;
	while(isOK == false)
	{
		int rd = (int)(CCRANDOM_0_1() * 4);
		
		if (rd != m_curRightAnswer)
		{
			if (m_itAnswers[rd]->isEnabled())
			{
				m_itAnswers[rd]->setEnabled(false);
				m_curDisableChoose++;
				
				DataManager::sharedDataManager()->AddDiamond(- diamond_for_exclusive);
				m_lbDiamond->setString(CCString::createWithFormat("%d", DataManager::sharedDataManager()->GetDiamond())->getCString());
				PLAY_GET_BOMB_EFFECT;
				isOK = true;
			}			
		}
	}
}