Cocos2D-X
간단하게 데이터 저장 - UserDefault 사용법
빵원군
2016. 6. 15. 21:53
간단하게 데이터를 저장하기위해
UserDefault 클래스를 사용한다.
이때 주의점은 Key는 붙여써야 하는것 같다.
XML로 저장되는데 Key에 공백이 있는 경우 제대로 불러오질 못한다.
UserDefault *def = UserDefault::getInstance(); auto highScore = def->getIntegerForKey("HIGHSCORE_FLAPPY", 0); if (score > highScore) { highScore = score; def->setIntegerForKey("HIGHSCORE_FLAPPY", highScore); } def->flush();
Windows 플랫폼의 경우 아래와 같은 경로에 XML이 생긴다.
%UserLocal%\GameName\UserDefault.xml