本文整理汇总了C++中AppDelegate::UpdateUserScore方法的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate::UpdateUserScore方法的具体用法?C++ AppDelegate::UpdateUserScore怎么用?C++ AppDelegate::UpdateUserScore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDelegate
的用法示例。
在下文中一共展示了AppDelegate::UpdateUserScore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showHint
bool MultiPriceMatch::showHint(){
bool bRet = false;
bool allset = true;
Vec2 vecbtn;
do{
if(_bTlEnabled == false) break;
_bTlEnabled = false;
AppDelegate *app = (AppDelegate*)Application::getInstance();
//long score = app->GetUserTotalScore();
int score = 0;
if (_nTlimit > 0){
if(_nTlcount > 0){
_nTlcount--;
//AppDelegate *app = (AppDelegate*) Application::getInstance();
app->setToolsNumberInfo(_nTlcount);
}else{
if(_lTtlScore >= 10){
showDeductPointEffect(LINK_UI_TEXT_SCORE);
score = 10;
_lTtlScore = _lTtlScore - 10;
AppDelegate *app = (AppDelegate*) Application::getInstance();
app->UpdateUserScore(0,10);
}else{
break;
}
}
app->PlayEffect(SOUND_TOOL_CLICK);
_nTlimit--;
if (_nTlimit == 0){
auto spTips = dynamic_cast<Button*>(_SORT_UINode->getChildByName(LINK_UI_BTN_TIPS));
CC_BREAK_IF(!spTips);
spTips->setEnabled(false);
spTips->setColor(ccc3(84,84,84));//not disabled button, so use color instead
}
}else {
break;
}
//if (score < 10) {
// MessageBox("Oops, Your score should be greater than 10 to use powerup","Spot it");
// break;
//}
//_vec_currentPos.clear();
//for (int i = 0; i < 3; i++){
// _vec_currentPos.push_back(_vec_btnPrice[i]->getPosition());
//}
//btnClear();
//int i,j = 0;
//_vec_Price_index
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
vecbtn = _vec_btnPrice[_vec_Price_index[i]]->getPosition();//get correct button position
if (_vec_lblPrice[i]->getName().compare(LBL_TAKEN) == 0){
if (_vec_lblPrice[i]->getPosition() == _vec_btnPrice[j]->getPosition()){
if (_vec_btnPrice[j]->getTitleText().compare(_product_list[i].price.c_str()) == 0){ //price is correct
j = 3;
break;
}else{//price is wrong
// vecbtn = _vec_btnPrice[_vec_Price_index[i]]->getPosition();//get correct button position
_vec_btnPrice[_vec_Price_index[i]]->setPosition(_vec_lblPrice[i]->getPosition()); // move correct button to the position
_vec_btnPrice[_vec_Price_index[i]]->setBright(false);
_vec_btnPrice[_vec_Price_index[i]]->setTouchEnabled(false);
_vec_btnPrice[j]->setPosition(_vec_originalPos[j]); //set wrong button back to original place
_vec_btnPrice[j]->setTouchEnabled(true);
_vec_btnPrice[j]->setBright(true);
_vec_lblPrice[i]->setName(LBL_TAKEN); //set new position is taken
j = 3;
i = 3;
break;
}
}
}else{
_vec_btnPrice[_vec_Price_index[i]]->setPosition(_vec_lblPrice[i]->getPosition()) ;
_vec_btnPrice[_vec_Price_index[i]]->setBright(false);
_vec_btnPrice[_vec_Price_index[i]]->setTouchEnabled(false);
//_vec_btnPrice[j]->setPosition(_vec_lblPrice[i]->getPosition()) ;
_vec_lblPrice[i]->setName(LBL_TAKEN);
j = 3;
i = 3;
break;
}
}
}
for (int i = 0; i < 3; i++){
if (_vec_lblPrice[i]->getPosition() == vecbtn){
_vec_lblPrice[i]->setName("");
}
}
//.........这里部分代码省略.........
示例2: onHttpRequestCompleted
void RegisterView::onHttpRequestCompleted(HttpClient *sender, HttpResponse *response)
{
std::string title = "\0";
std::string msg = "\0";
if (!response)
{
title = "Register Error\0";
msg = "Register Error.\0";
ShowMsg(title, msg);
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());
log("response code: %d", statusCode);
if (!response->isSucceed())
{
log("response failed");
log("error buffer: %s", response->getErrorBuffer());
title = "Register Error\0";
msg = "Register Error.\0";
ShowMsg(title, msg);
return;
}
if (statusCode != 200){
log("response code failed");
log("error buffer: %s", response->getErrorBuffer());
title = "Register Error\0";
msg = "Register Error.\0";
ShowMsg(title, msg);
return;
}
// dump data
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("mobileAppRegister");
std::string strError=nodes.child_value("error");
char p[100];
strcpy(p,strError.c_str());
if(atoi(p)==0)
{
//get user guid
string strUserGuid=nodes.child_value("UserGuid");
/*UserDefault::getInstance()->setStringForKey("UserGuid", strUserGuid);
UserDefault::getInstance()->setIntegerForKey("remember_me", 1);
UserDefault::getInstance()->setStringForKey("tweebaa_username", sUserName);
UserDefault::getInstance()->setStringForKey("tweebaa_Password", sPassword);
UserDefault::getInstance()->flush();*/
AppDelegate *app = (AppDelegate*)Application::getInstance();
sUserName = app->base64_xxtea_encode(sUserName);
sPassword = app->base64_xxtea_encode(sPassword);
string strTool = DataAccess::getParamValue("Total_Tool_Num","\0");
int iTool=0;
if (strTool.length() > 0)
{
iTool = atoi(app->base64_xxtea_decode(strTool).c_str());
}
DataAccess::addUser(strUserGuid, sUserName, sPassword);
_UserInfo userInfo = DataAccess::getUserInfoByName(sUserName);
m_UserID = userInfo.nUserID;
UserDefault::getInstance()->setIntegerForKey("CurrentUserId", m_UserID);
app->UpdateUserScore(1, 50);
char sTool[10];
sprintf(sTool, "%d", iTool + 10);
strTool = sTool;
strTool = app->base64_xxtea_encode(strTool);
DataAccess::setParamValue("Total_Tool_Num", strTool);
//get it
//string s=CCUserDefault::sharedUserDefault()->getStringForKey("UserGuid");
//auto scene = CollageMainTab::createScene();
/*auto scene = ChooseLayer::createScene();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);*/
this->cleanup();
m_Refresh = 1;
Director::getInstance()->popScene();
}
if(atoi(p)==-1){
title = "Input Error\0";
//.........这里部分代码省略.........
示例3: touchButton
void GameLayer::touchButton(Object* obj, ::ui::Widget::TouchEventType eventType)
{
auto button = dynamic_cast<::ui::Button*>(obj);
int tag = button->getTag();
if (eventType == ::ui::Widget::TouchEventType::ENDED)
{
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->PlayEffect(SOUND_BUTTON_CLICK);
if (tag == 2001)
{ //Tutorial
auto scene = TutorialScene::create();
if (scene != nullptr){
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->pushScene(transition);
}
}
if (tag == 2002)
{ //Home
MsgBoxType m_type = TP_Q_YESNO;
std::string title = MSG_QUIT_TITLE;
std::string msg = MSG_QUIT_MSG;
MsgBox::setMsgBox(m_type, &title, &msg);
auto msgbox = MsgBox::create();
msgbox->setTag(9000);
this->addChild(msgbox, 999);
//Add Event to process
auto btnYes = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_Yes"));// Magnifier Button
auto btnNo = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_No"));// Magnifier Button
btnYes->addTouchEventListener(CC_CALLBACK_2(GameLayer::yesCallback, this));
btnNo->addTouchEventListener(CC_CALLBACK_2(GameLayer::noCallback, this));
}
if (tag == 2003)
{ //AI tips
if (_bTlEnabled == false) return;
_bTlEnabled = false;
if (_nTlimit > 0)
{
if (_nTlcount > 0)
{
_nTlcount--;
//AppDelegate *app = (AppDelegate*)Application::getInstance();
app->setToolsNumberInfo(_nTlcount);
}
else
{
if (_lTtlScore >= 10)
{
showDeductPointEffect("txtScore");
_lTtlScore = _lTtlScore - 10;
//AppDelegate *app = (AppDelegate*)Application::getInstance();
app->UpdateUserScore(0, 10);
}
else return;
}
_nTlimit--;
if (_nTlimit == 0)
{
auto spTips = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTipsTools"));
spTips->setColor(ccc3(84, 84, 84));//not disabled button, so use color instead
}
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_TOOL_CLICK);
}
UseTips();
this->scheduleOnce(schedule_selector(GameLayer::enableTools), 2.0f);
}
else return;
}
}
}