예제 #1
0
std::string GameWin::updateFlow()
{
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	std::string strLocal=DataAccess::getParamValue("LocalFlow");
	if (strLocal.length() > 0)
	{
		strLocal = app->base64_xxtea_decode(strLocal);//format:x,x,x,x,x,x,
		string::size_type pos;
		string sSub;
		for (int i = 0; i < 6; i++)
		{
			pos = strLocal.find(",");
			if (pos != string::npos)//found
			{
				sSub = strLocal.substr(0, pos);
				strLocal = strLocal.substr(pos + 1, strLocal.size() - 1);
				m_iLocal[i] = atoi(sSub.c_str());
			}
			else return "\0";//wrong 
		}
		m_iLocal[m_iCurrentGameID - 1] += iReward;
	}
	else  m_iLocal[m_iCurrentGameID - 1] = iReward;
	char cFlow[20] = "\0";
	std::string strFlow = "";
	for (int i = 0; i < 6; i++)
	{
		if (m_iLocal[i]>0)
		{
			sprintf(cFlow, "%d:%d,\0", i + 1, m_iLocal[i]);
			strFlow += cFlow;
		}
	}
	return strFlow;
}
예제 #2
0
파일: main.cpp 프로젝트: bhlzlx/graphics
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
    if(action == GLFW_REPEAT || action == GLFW_PRESS)
    {
        mouseEvent.eventType = eMouseDown;
        switch(button)
        {
        case GLFW_MOUSE_BUTTON_LEFT:
            mouseEvent.button = eMouseButtonLeft;
            break;
        case GLFW_MOUSE_BUTTON_RIGHT:
            mouseEvent.button = eMouseButtonRight;
            break;
        case GLFW_MOUSE_BUTTON_MIDDLE:
            mouseEvent.button = eMouseButtonMid;
            break;
        }
        appDelegate.AppMouseAction(&mouseEvent);
    }
    else
    {
        mouseEvent.eventType = eMouseUp;
        appDelegate.AppMouseAction(&mouseEvent);
        mouseEvent.button = eMouseButtonInvalid;
    }

}
예제 #3
0
void MultiPriceMatch::menuKeyCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){

	AppDelegate *app = (AppDelegate*)Application::getInstance();


	switch (eEventType) {
		case ui::Widget::TouchEventType::BEGAN:
			cocos2d::log("touch Began");
			break;
		case ui::Widget::TouchEventType::ENDED:
			cocos2d::log("touch Ended");
			if (app->getBGMstatus() == BGMusic_flag::ON){
				app->PlayEffect(SOUND_BUTTON_CLICK);
			}	
			MultiPriceMatch::gameover(); //quit the game
			break;
		case ui::Widget::TouchEventType::MOVED:
			cocos2d::log("touch Cancel");
			break;
		case ui::Widget::TouchEventType::CANCELED:
			cocos2d::log("touch Cancel");
			break;
		default:
			cocos2d::log("touch Default");
			break;
	}
	return;

}
예제 #4
0
void MultiPriceMatch::yesCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
    if (type == cocos2d::ui::Widget::TouchEventType::ENDED){

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

		_vec_circle.clear();
		_vec_circle2.clear();
		this->unschedule(schedule_selector(MultiPriceMatch::updateTimeLabel));
		//this->unschedule(schedule_selector(FindDiffLayer::updateDragMove));

		//AppDelegate *app = (AppDelegate*)Application::getInstance();
//		app->SaveGamePassLevel();
		app->moveToNextGameLevel();

		if (app->iGameMode == MobileGameMode::Theme_Mode)
		{
			auto scene = ThemeLayer::createScene();
			TransitionScene *transition = TransitionFade::create(1, scene);
			Director::getInstance()->replaceScene(transition);
		}
		else
		{
			auto scene = WelcomeScene::create();
			TransitionScene *transition = TransitionFade::create(1, scene);
			Director::getInstance()->replaceScene(transition);
		}

		this->removeChildByTag(9000);
        CCLOG("touch ended.");
    }
}
예제 #5
0
void GameLayer::yesCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type)//quit game button
{
	if (type == cocos2d::ui::Widget::TouchEventType::ENDED)
	{

		AppDelegate *app = (AppDelegate*)Application::getInstance();
		app->PlayEffect(SOUND_BUTTON_CLICK);
		app->moveToNextGameLevel();

		this->unschedule(schedule_selector(GameLayer::updateLabels));
		this->unschedule(schedule_selector(GameLayer::updateTimeLabel));


		if (app->iGameMode == MobileGameMode::Theme_Mode)
		{
			auto scene = ThemeLayer::createScene();
			TransitionScene *transition = TransitionFade::create(1, scene);
			Director::getInstance()->replaceScene(transition);
		}
		else
		{
			auto scene = WelcomeScene::create();
			TransitionScene *transition = TransitionFade::create(1, scene);
			Director::getInstance()->replaceScene(transition);
		}

		this->removeChildByTag(9000);
		CCLOG("touch ended.");
	}
}
예제 #6
0
파일: main.cpp 프로젝트: bhlzlx/graphics
int main(int argc,char ** argv)
{
    // start GL context and O/S window using the GLFW helper library
    appDelegate.AppWillStart();
    FPS_Helper fpsHelper;
    fpsHelper.SetFixedFPS(30);
    InitOpenGL();

    appDelegate.AppDidStart();

    while (!glfwWindowShouldClose (mainWnd.window))
    {
        // wipe the drawing surface clear
        static double timer_last = 0;
        double curr_time = glfwGetTime();
        if(curr_time - timer_last > 0.2)
        {
            timer_last = timer_last + 0.02;
            OnTimer();
        }

        if(fpsHelper.Tick())
        {
            OnRender();
            // update other events like input handling
            glfwPollEvents ();
            // put the stuff we've been drawing onto the display
            glfwSwapBuffers (mainWnd.window);
        }
    }
    // close GL context and any other GLFW resources
    appDelegate.AppWillTerminate();
    glfwTerminate();
    return 0;
}
예제 #7
0
void GameWin::onSyncCompleted(HttpClient *sender, HttpResponse *response){
	if (!response)
	{
		updateLocalFlow();
		return;
	}

	// You can get original request type from: response->request->reqType
	if (0 != strlen(response->getHttpRequest()->getTag()))
	{
		log("%s completed", response->getHttpRequest()->getTag());
	}
	int statusCode = response->getResponseCode();
	char statusString[64] = {};
	sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
	// _labelStatusCode->setString(statusString);
	log("response code: %d", statusCode);
	if (!response->isSucceed())
	{
		log("response failed");
		log("error buffer: %s", response->getErrorBuffer());
		updateLocalFlow();
		return;
	}
	if (statusCode != 200){
		log("response code failed");
		log("error buffer: %s", response->getErrorBuffer());
		updateLocalFlow();
		return;
	}
	clearLocalFlow();

	// dump data
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	std::vector<char> *buffer = response->getResponseData();
	string sXml(buffer->begin(), buffer->end());
	pugi::xml_document doc;
	pugi::char_t cXml[1024];
	strcpy(cXml, sXml.c_str());
	pugi::xml_parse_result result = doc.load_string(cXml);

	pugi::xml_node nodes = doc.child("mobileAppSyncPoint");

	std::string strResult = nodes.child_value("result");
	char p[100];
	strcpy(p, strResult.c_str());
	int iScore = atoi(p);
	if (iScore==0)
	{
		//get TotalPoints
		 strResult = nodes.child_value("TotalPoints");
		 app->SaveUserScoreDiff(atoi(strResult.c_str()));
		//get TotalTools
		strResult = nodes.child_value("TotalTools");
		app->SaveUserToolsDiff(atoi(strResult.c_str()));
	}

}
예제 #8
0
void GameLayer::noCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type)
{
	if (type == cocos2d::ui::Widget::TouchEventType::ENDED)
	{
		AppDelegate *app = (AppDelegate*)Application::getInstance();
		app->PlayEffect(SOUND_BUTTON_CLICK);
		this->removeChildByTag(9000);
	}
}
예제 #9
0
void GameWin::CallbackRegisterNo(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
	if (type == cocos2d::ui::Widget::TouchEventType::ENDED)         {
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	if (app->getBGMstatus() == BGMusic_flag::ON){
		app->PlayEffect(SOUND_BUTTON_CLICK);
	}

	switch (m_iCurrentGameID){
			case 1:{
				auto scene = FindDiffScene::create();
				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
				   break;

			case 2:{
				auto scene = ZoomGameScene::create();
				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
				   break;
			case 3:{


				auto scene = jigSawScene::create();

				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
				   break;
			case 4:{
				auto scene = GameScene::create();


				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
				   break;

			case 5:{
				auto scene = PriceMatchScene::create();


				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
				   break;
			case 6:
			{
				auto scene = MultiPriceMatchScene::create();
				TransitionScene *transition = TransitionFade::create(1, scene);
				Director::getInstance()->replaceScene(transition);
			}
		}			
		this->removeChildByTag(9000);
	}
}
예제 #10
0
void EventBoard::btnQuitCallBack(Ref* pSender, ui::Widget::TouchEventType eEventType){
	if (eEventType == cocos2d::ui::Widget::TouchEventType::ENDED){
		AppDelegate *app = (AppDelegate*)Application::getInstance();
		app->PlayEffect(SOUND_BUTTON_CLICK);
		this->cleanup();
		Director::getInstance()->popScene();
	}
	return;
}
예제 #11
0
void MainWindow::updateServerAddressLabel() {
    AppDelegate* app = AppDelegate::getInstance();

    _serverAddressLabel->setText("<html><head/><body style=\"font:14pt 'Helvetica', 'Arial', 'sans-serif';"
                                 "font-weight: bold;\"><p><span style=\"color:#545454;\">Accessible at: </span>"
                                 "<a href=\"" + app->getServerAddress() + "\">"
                                 "<span style=\"color:#29957e;\">" + app->getServerAddress() +
                                 "</span></a></p></body></html>");
    _serverAddressLabel->adjustSize();
}
예제 #12
0
void GameWin::CallbackRegisterYes(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
	if (type == cocos2d::ui::Widget::TouchEventType::ENDED){
		AppDelegate *app = (AppDelegate*)Application::getInstance();
		if (app->getBGMstatus() == BGMusic_flag::ON){
			app->PlayEffect(SOUND_BUTTON_CLICK);
		}

		GameWin::showRegister();
	}
}
예제 #13
0
void GameLayer::GameFailed(){
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	app->moveToNextGameLevel();

	this->unschedule(schedule_selector(GameLayer::updateLabels));
	this->unschedule(schedule_selector(GameLayer::updateTimeLabel));

	auto scene = GameFailed::createScene();
	TransitionScene *transition = TransitionFade::create(1, scene);
	Director::getInstance()->replaceScene(transition);
}
예제 #14
0
void MultiPriceMatch::PlayAnimation(float dt)
{
	Armature *armature = dynamic_cast<Armature *>(_SORT_UINode->getChildByTag(888));
	armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
	armature->getAnimation()->setSpeedScale(0.8);
	AppDelegate* app = (AppDelegate*)Application::getInstance();
	if (app->getBGMstatus() == BGMusic_flag::ON)
	{
		app->PlayEffect(SOUND_ANIMATION);
	}
}
예제 #15
0
void GameWin::updateLocalFlow()
{
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	char cFlow[20] = "\0";
	std::string strLocal = "";
	for (int i = 0; i < 6; i++)
	{
		sprintf(cFlow, "%d,\0",  m_iLocal[i]);
		strLocal += cFlow;
	}
	strLocal = app->base64_xxtea_encode(strLocal); 
	DataAccess::setParamValue("LocalFlow", strLocal);
	DataAccess::setParamValue("SyncFlag", "1");
}
예제 #16
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
					   HINSTANCE hPrevInstance,
					   LPTSTR    lpCmdLine,
					   int       nCmdShow){
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	g_hInstance = hInstance;

	int nRet = 0;
	AppDelegate app;
	nRet = app.Run();

	return nRet;
}
예제 #17
0
void MultiPriceMatch::btnPriceCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
	/*if (eEventType != ui::Widget::TouchEventType::BEGAN)*/

	CCNode* node = (CCNode*) pSender;
	int tag = node->getTag();
	bool bSel = false;

	for (int i = 0; i < 3;i++){
		if (tag == (BTN_PRICE_1 + i)) bSel = true;
	}

	if (bSel == false) return;

	cocos2d::log("button's tag is %d",tag);
	auto button = (Button*) _SORT_UINode->getChildByTag(tag);
	AppDelegate *app = (AppDelegate*)Application::getInstance();


	switch (eEventType) {
		case ui::Widget::TouchEventType::BEGAN:
			cocos2d::log("btnPriceCallback Began");
			button->getTouchBeganPosition();
			button->setZOrder(99);
			break;
		case ui::Widget::TouchEventType::ENDED:
			cocos2d::log("btnPriceCallback Ended");
			if (app->getBGMstatus() == BGMusic_flag::ON){
				app->PlayEffect(SOUND_BUTTON_CLICK);

			}	
			button->setZOrder(1);
			MovetoPriceLabel(button);
			break;
		case ui::Widget::TouchEventType::MOVED:
			button->setPosition(button->getTouchMovePosition());
			cocos2d::log("btnPriceCallback Moving");
			break;
		case ui::Widget::TouchEventType::CANCELED:
			cocos2d::log("touch Cancel");
			button->setZOrder(1);
			break;
		default:
			cocos2d::log("touch Default");
			break;
	}
	return;

}
예제 #18
0
    void onMouseButton(int button, int action, int mods)
    {
        base::MouseButtonEvent ev;

        if (action == GLFW_PRESS)
            ev.state = base::MouseButtonEvent::State::PRESSED;
        else if (action == GLFW_RELEASE)
            ev.state = base::MouseButtonEvent::State::RELEASED;
        else
            return;

        if (button == GLFW_MOUSE_BUTTON_LEFT)
            ev.button = base::MouseButtonEvent::Button::LEFT;
        else if (button == GLFW_MOUSE_BUTTON_RIGHT)
            ev.button = base::MouseButtonEvent::Button::RIGHT;
        else if (button == GLFW_MOUSE_BUTTON_MIDDLE)
            ev.button = base::MouseButtonEvent::Button::MIDDLE;
        else
            return;

        double xpos, ypos;
        glfwGetCursorPos(window, &xpos, &ypos);

        ev.x = (int)xpos;
        ev.y = (int)ypos;

        m_appDelegate->onMouseButtonEvent(ev);
    }
예제 #19
0
void MultiPriceMatch::noCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
    if (type == cocos2d::ui::Widget::TouchEventType::ENDED){
			
		AppDelegate *app = (AppDelegate*)Application::getInstance();
		if (app->getBGMstatus() == BGMusic_flag::ON){
			app->PlayEffect(SOUND_BUTTON_CLICK);
		}		
		
		//Don't quit the game
		this->removeChildByTag(9000);
		//enable the touch event
		//CallFunc *runCallback = CallFunc::create(CC_CALLBACK_0(FindDiffLayer::resetTouchEvent, this));
		//this->runAction(Sequence::create(DelayTime::create(1.0f), runCallback, nullptr));
        CCLOG("touch ended.");
    }
}
예제 #20
0
void MultiPriceMatch::ShowTutorialCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
	if (eEventType == cocos2d::ui::Widget::TouchEventType::ENDED){

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

		auto scene = TutorialScene::create();
		if(scene != nullptr){
			TransitionScene *transition = TransitionFade::create(1, scene);
			Director::getInstance()->pushScene(transition);
		}

	}
}
예제 #21
0
파일: main.cpp 프로젝트: bhlzlx/graphics
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	if(action != GLFW_PRESS)
	{
		appDelegate.AppKeyPressed(key,mouseEvent.lastX,mouseEvent.lastY);
	}    
}
예제 #22
0
void MultiPriceMatch::gamewin(){

	long curscore = m_iUserTotalScore;
	AppDelegate *app = (AppDelegate*)Application::getInstance();
	this->unschedule(schedule_selector(MultiPriceMatch::updateTimeLabel));

	int score = 0;
	int ttlseconds = _gametime / 60;

	//std::string strSKU = "1400039210";
	//app->setPromoteProduct("");
	//if(app->getGameLevelPassedInfo() == 0){
	//	if (ttlseconds > 60 && ttlseconds <= 90){
	//		score = WIN_POINT_HIG;
	//	}else if(ttlseconds > 30 && ttlseconds <= 60){
	//		score = WIN_POINT_MED;	
	//	}else{rea
	//		score = WIN_POINT_LOW;
	//	}
	//}else{
	//	score = WIN_POINT_LOW;		
	//}

	//_gamestatus = GAME_OVER;
	_vec_circle.clear();
	_vec_circle2.clear();
	

    
//	AppDelegate *app = (AppDelegate*)Application::getInstance();
	if(app->iGameMode == MobileGameMode::Theme_Mode){
		app->GameRunRoundNext();
	}else{
		//app->UpdateUserScore(1,score);
		//app->setReward(score);
		app->updateGameWinScore(ttlseconds);
		app->SaveGamePassLevel();//Add by Long to Save Level
		app->moveToNextGameLevel();
		this->scheduleOnce(schedule_selector(MultiPriceMatch::delayWinQuit),1.0f);
		//auto scene = GameWin::createScene();
		//if(scene != nullptr){
		//	TransitionScene *transition = TransitionFade::create(1, scene);
		//	Director::getInstance()->replaceScene(transition);
		//}
	}
}
예제 #23
0
int main(int argc, char **argv)
{

	int exit_code = 0;

	bool bServiceMode = false;
	bool bInterpreterMode = false;

	std::string sCmdLine;

	for(int i=1;i<argc; ++i)
	{
		// for linux, we will check the command line to see if it contains "-d", which will run in service mode.
		if(strcmp(argv[i], "-d") == 0)
		{
			bServiceMode = true;
		}
		else if(strcmp(argv[i], "-D") == 0)
		{
			bServiceMode = false;
		}
		else if(strcmp(argv[i], "-i") == 0)
		{
			bInterpreterMode = true;
		}
		else if (argv[i])
		{
			if (sCmdLine.empty())
				sCmdLine = argv[i];
			else
			{
				sCmdLine += " ";
				sCmdLine += argv[i];
			}
		}
	}

    AppDelegate* app = new AppDelegate();
    app->SetMacCommandLine(sCmdLine);

    app->Run();

    return 0;
}
예제 #24
0
    void onKey(int key, int scancode, int action, int mods)
    {
        int keyModifiers = 0;
        if (mods & GLFW_MOD_SHIFT)
            keyModifiers |= base::KeyboardEvent::KM_SHIFT;
        if (mods & GLFW_MOD_ALT)
            keyModifiers |= base::KeyboardEvent::KM_ALT;
        if (mods & GLFW_MOD_CONTROL)
            keyModifiers |= base::KeyboardEvent::KM_CTRL;

        base::KeyboardEvent ev;
        ev.keycode = convertGlfwKeyCode(key);
        ev.modifiers = static_cast<base::KeyboardEvent::KeyModifier>(keyModifiers);

        if (action == GLFW_PRESS)
            m_appDelegate->onKeyDown(ev);
        else if (action == GLFW_RELEASE)
            m_appDelegate->onKeyUp(ev);
    }
예제 #25
0
파일: main.cpp 프로젝트: BigHand/cocos2d-x
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv*  env, jobject thiz, jint w, jint h)
{
    if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
    {
        cocos2d::CCEGLView *view = new cocos2d::CCEGLView();
        view->setFrameWitdAndHeight(w, h);
        cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);

        CCFileUtils::setRelativePath(IMG_PATH);

        AppDelegate app;
        app.Run();
    }
    else
    {
        cocos2d::CCTexture2D::reloadAllTextures();
        cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
    }
}
예제 #26
0
    glfwApplication(AppDelegate *appDelegate)
        : m_appDelegate(appDelegate)
    {
        // Create window and OpenGL context.
        if (!glfwInit())
            throw std::runtime_error("Failed to init glfw");

        glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

        const auto params = m_appDelegate->getInitParams();

        GLFWmonitor *monitor = params.fullscreen ? glfwGetPrimaryMonitor() : nullptr;

        window = glfwCreateWindow(params.windowWidth, params.windowHeight, "libdf3d_window", monitor, nullptr);
        if (!window)
        {
            throw std::runtime_error("Failed to create glfw window");
            glfwTerminate();
        }

        // Center the window.
        auto videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
        if (videoMode && !params.fullscreen)
            glfwSetWindowPos(window, (videoMode->width - params.windowWidth) / 2, (videoMode->height - params.windowHeight) / 2);

        glfwMakeContextCurrent(window);
        glfwSetWindowUserPointer(window, this);

        if (params.vsync)
            glfwSwapInterval(1);

        // Set input callbacks.
        glfwSetCursorPosCallback(window, cursorPositionCallback);
        glfwSetMouseButtonCallback(window, mouseButtonCallback);
        glfwSetKeyCallback(window, keyCallback);
        glfwSetCharCallback(window, textInputCallback);
        glfwSetScrollCallback(window, scrollCallback);

        // Init user code.
        if (!m_appDelegate->onAppStarted(params.windowWidth, params.windowHeight))
            throw std::runtime_error("Game code initialization failed.");
    }
예제 #27
0
void MultiPriceMatch::gamelose(){
	_vec_circle.clear();
	_vec_circle2.clear();
	//_gamestatus = GAME_OVER;

	this->unschedule(schedule_selector(MultiPriceMatch::updateTimeLabel));

	AppDelegate *app = (AppDelegate*)Application::getInstance();
//	app->SaveGamePassLevel();//Add by Long to Save Level
	//std::string strSKU = "1400039210";
	//app->setPromoteProduct("");

	app->moveToNextGameLevel();
	this->scheduleOnce(schedule_selector(MultiPriceMatch::delayFailQuit),1.0f);
	//auto scene = GameFailed::createScene();
	//if(scene != nullptr){
	//	TransitionScene *transition = TransitionFade::create(1, scene);
	//	Director::getInstance()->replaceScene(transition);
	//}
}
예제 #28
0
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
	}
}
예제 #29
0
    void run()
    {
        using namespace std::chrono;

        TimePoint currtime, prevtime;
        currtime = prevtime = system_clock::now();

        while (!glfwWindowShouldClose(window))
        {
            currtime = system_clock::now();

            m_appDelegate->onAppUpdate(IntervalBetween(currtime, prevtime));

            glfwSwapBuffers(window);

            prevtime = currtime;

            glfwPollEvents();
        }

        m_appDelegate->onAppEnded();
    }
예제 #30
0
void GameLayer::PlayAnimation(float dt)
{
	Armature *armature = dynamic_cast<Armature *>(_rootNode->getChildByTag(888));
	if (nAniFlag == 1)
	{
		armature->setPosition(Vec2(200, 400));
		armature->setRotation(270);
		nAniFlag = 2;
	}
	else
	{
		armature->setPosition(Vec2(800, 200));
		armature->setRotation(180);
		nAniFlag = 1;
	}
	armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
	AppDelegate* app = (AppDelegate*)Application::getInstance();
	if (app->getBGMstatus() == BGMusic_flag::ON)
	{
		app->PlayEffect(SOUND_ANIMATION);
	}
}