Build fingerprint: 'lge/b2lds_global_com/b2lds:4.4.2/KOT49I.A1420806068/1420806068:user/release-keys'
Stack frame #01 pc 0028c6c5 /data/app-lib/com.baiph.baiwordwars-1/libcocos2dcpp.so (MainMenu::energy_update()+108): Routine MainMenu::energy_update() at /home/soysoy/baiph/3.3final/WordWars/proj.android/jni/../../Classes/MainMenu.cpp:1116
void MainMenu::energy_update() // update on UI
{
float finalscale;
if(energy_num>ENERGY_MAX)
finalscale = (bar_max/ENERGY_MAX)*ENERGY_MAX;
else
finalscale = (bar_max/ENERGY_MAX)*energy_num;
energy_bar->setScale(finalscale,GETSCALEY*1.24);
energy_bar->setPosition(energy_base->getPositionX()*0.46+energy_bar->getBoundingBox().size.width/2,
energy_base->getPositionY()*1.005);
std::string energy_str = std::to_string(energy_num);
energy_str.append("/");
energy_str.append(std::to_string(ENERGY_MAX));
energy->setString(energy_str);
energy->setPosition(energy_base->getPositionX()*1.1,energy_bar->getPositionY()*0.97);
if(isFirstLaunch)
{
isFirstLaunch = !isFirstLaunch;
def->setBoolForKey("isFirstLaunch",isFirstLaunch);
def->flush();
}
rewardDone=true;
if(!connected)
{
hide_layer(network_layer, true, 0);
hide_layer(HUD_main, false, 255);
hide_layer(main_menu, false, 255);
}
main_menu->setEnabled(true);
requests_menu->setEnabled(true);
challenge_menu->setEnabled(true);
connected = true;
}
void MainMenu::onTimerServiceRequestCompleted( void *response, std::string action)
{
log("//*************************************************//");
log("\nonTimerServiceRequestCompleted... action %s", action.c_str());
App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
if(app42TimerResponse->isSuccess)
{
log("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
if(action=="CREATE")
{
timeLeft = TIME_PER_ENERGY_S;
timerService->CreateOrUpdateTimer(timerName.c_str(),timeLeft,app42callback(MainMenu::onTimerServiceRequestCompleted, this, "START"));
}
else if(action=="START")
{
timerService->StartTimer(timerName.c_str(),userName.c_str(),app42callback(MainMenu::onTimerServiceRequestCompleted, this, "STARTED"));
}
else if(action=="STARTED")
{
auto scheduler = Director::getInstance()->getScheduler();
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::time_diff, this,app42TimerResponse->app42Timer.endTime, app42TimerResponse->app42Timer.startTime));
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::energy_update, this));
isCounting = true;
}
else if(action=="CURRENTTIME")
{
if(energy_num<ENERGY_MAX)
{
server_time = app42TimerResponse->app42Timer.currentTime; //CURRENT TIME
time_diff(server_end, server_time);
auto scheduler = Director::getInstance()->getScheduler();
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::energy_update, this));
isCounting = true;
}
}
else if(action=="CHECK")//UPDATES
{
if(app42TimerResponse->app42Timer.isTimerActive)
{
server_end = app42TimerResponse->app42Timer.endTime;
server_start = app42TimerResponse->app42Timer.startTime;
timerService->GetCurrentTime(app42callback(MainMenu::onTimerServiceRequestCompleted, this,"CURRENTTIME"));
}
else if(energy_num<ENERGY_MAX)
{
//double energy_max = 3;
double energy_lost = ENERGY_MAX-energy_num;
auto scheduler = Director::getInstance()->getScheduler();
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::add_energy, this,true,energy_lost,"TIMER_CREATE"));
}
}
else if(action=="ADD_ON_RUNTIME")
{
auto scheduler = Director::getInstance()->getScheduler();
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::add_energy, this,true,1,"UPDATE_UI"));
if(app42TimerResponse->app42Timer.isTimerActive)
{
server_end = app42TimerResponse->app42Timer.endTime;
timerService->GetCurrentTime(app42callback(MainMenu::onTimerServiceRequestCompleted, this,"CURRENTTIME"));
}
}
}
else
{
log("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
log("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
log("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
log("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
if((action=="CREATE") || (action=="START") ||(action=="STARTED"))
{
auto scheduler = Director::getInstance()->getScheduler();
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(MainMenu::energy_update, this));
}
}
log("//*************************************************//");
}
Problem is, If there is an on going requests and then I switch scene the callback is still fired. Is there a way to stop the callback?