Hi,
I am porting a game from iOS to android use cocos2d-x, and I want to find a replacement to NSUserDefaults.
After a few try, I found the CCUserDefault seems to be my answer.
When I call something like this : “CCUserDefault::sharedUserDefault()->setIntegerForKey(”egg_num“, 1);” on android, it just crash.
But this is fine at iOS build. Can somebody help me about this issue?
Thank you.
Sorry…
I found there is a same issue posted before(http://www.cocos2d-x.org/boards/10/topics/4226 ).
I will wait for a new build to fix this bug.
Or do you guys have another way to do the same thing?
Thank you.
ssmac
October 7, 2011, 7:36pm
#3
I am experiencing the same problem, but for me its CCFileUtils::getWritablePath() that actually crashes (simulator and actual device).
I can easily reproduce it by just generating a template android project, and adding the above line anywhere.
to Steve S:
CCFileUtils::getWritablePath() crash bug has been resolve in the latest code, and 0.9.2 will be published within a few days
to Steve S:
CCFileUtils::getWritablePath() crash bug has been resolved in the latest code, and 0.9.2 will be published within a few days
ssmac
October 7, 2011, 8:16pm
#6
Awesome, thanks for the fast response!
Tried to checkout the latest via:
$ git clone https://github.com/cocos2d/cocos2d-x.git
Initialized empty Git repository in …/test/cocos2d-x/.git/
fatal: https://github.com/cocos2d/cocos2d-x.git/info/refs download error - The requested URL returned error: 403
Am I using a bad url for the repo?
ye, the url is right : https://github.com/cocos2d/cocos2d-x.git
did you download the cocos2d-x code from github before?
you could try if you could enter the page https://github.com/cocos2d/cocos2d-x/
or maybe you need a github account.
ssmac
October 7, 2011, 8:34pm
#8
Got it
git clone —depth 1 git://github.com/cocos2d/cocos2d-x.git
worked for me.
ssmac
October 7, 2011, 8:55pm
#9
Ok, rebuilt my project against the latest sources, and CCFileUtils::getWritablePath() now works as expected.
Thanks.
Can you give me a more detail instruction about how to change current version cocos2d-x to this version?
I need this to make my android porting progress continue.
Thank you in advance.
huangrh
October 8, 2011, 12:11am
#11
you could use git to download the source code from https://github.com/cocos2d/cocos2d-x.git or git://github.com/cocos2d/cocos2d-x.git,
or you could enter https://github.com/cocos2d/cocos2d-x/ and click the download button on the upper-right corner to download the source code.
then you could put your own project things in the corresponding position in the -x directory or you could directly replace the engine code of your project with the downloaded code.
btw, the setXXXForKey() bug has been resolved.
http://www.cocos2d-x.org/issues/744
Hi,
Thank you for your help, I am using this new version smoothly.