The following is all I call in update
void MyScene::updateClock() {
static int lastMinute = 0;
char str[10] = {0};
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime (&rawtime);
if (forceClockUpdate || lastMinute != timeinfo->tm_min) {
lastMinute = timeinfo->tm_min;
forceClockUpdate = false;
strftime (str, 9,"%R",timeinfo);
pTimeLabel->setString(str);
}
}
I was updating another timer in there but the app would crash, on the emulator (only), after about 7 seconds. I removed that update and I had at least 20 seconds to play, inspect the log etc but upon returning to it I found that it had frozen again. Even the cocos2d-x stuff like framerate in the bottom left had stopped. I’m using TTF for my label, could it be that running too slow? I doubt it because whatever refresh I stipulate
schedule(schedule_selector(MyScene::update), 1.2f); //or
scheduleUpdate();
It still tends to lock up. Before I changed the data structure it was alright, but the old data structure was so unwieldly that the whole app was being debugged on my phone only.
Thanks.
UPDATE
This one isn’t working on my phone at all, as it attempts to load I get a brief message about waiting for debugger and, ohhh, there it goes logcat is scrolling but the screen refuses to turn back on
Fixed that but not risking my phone again. After removing updating the TTFLabel it seemed okay. Had some errors returned when I attempted to close it, about heap allocations, tried fixing them and now it just refuses to build citing errors with four of my “.o” files.
Development with Visual Studio was childs play compared to this.
UPDATE2
I had some joy on the emulator, only after restarting eclipse and the emulator. The joy ended as soon as I reinstated the second part of the update routine described, but not shown above:
if (hasTime) {
sprintf(str, “%d:%2d”, int(timeRemaining) / 60, int(timeRemaining) % 60);
pTimerLabel->setString(str);
}
This would update 50x/second so could understandably cause a hang. Or worse. So restarted my emulator and made a static local to detect when the second had changed. It was still failing after 7s despite having only introduced “nominal” overhead. I removed it altogether and it last at least 20s.
On start up I am getting the following message:
Which I’ve only had since I introduced a new quarter second (on emulator) task to occur before the first screen.