I’m saving my highscore value using CCUserdefault like so
@
CCUserDefault::sharedUserDefault()->setIntegerForKey(“highScore”, appDelegate.score);
int highScore = CCUserDefault::sharedUserDefault()->getIntegerForKey(“highScore”);
@
This works fine while the game is running. But if I close and restart the game it goes back to 0. Is this how it works or is there something I’m missing?
What’s the problem was? Did someone face with this problem on windows? Is that bug exists now on windows? (if this is a bug, of course).
As described above; The functionality changed, needed to call flush after saving your data to ensure it actually got written -> CCUserDefault::sharedUserDefault()->flush();
Hi. I’m experiencing this problem with WP8, even after invoking flush(). Strangely it works only in the emulator but it doesn’t work on the device I was testing: Lumia 620. I’m using cocos2dx 2.2.
After some investigation, I realized flush() is empty, and the save function has been moved to setValueForKey(), which means flush() is no longer needed and all setXXXXForKey() should save the values right away. However, my issue with the device is not yet solved. The filename parameter passed in to tinyxml2.cpp always turned to garbage, which I first believe what causing the save to fail. In desperate attempt, I tried hardcoding the filename in SaveFile() in tinyxml2, but to no avail. So I’m quite lost at what to do now.