Skip to content
Search

Cocos2dx:CCUserDefault

lastmod 2018-08-17created 2017-11-101 edits

To save a small amount of file data, use CCUserDefault.

Example

Saving is done as follows.

CCUserDefault * gameData = CCUserDefault::sharedUserDefault();
gameData->setIntegerForKey("stageInfo_x", location.x);
gameData->flush();

With a buffered output stream, a write operation is not reflected immediately; it is reflected only when the buffer fills up or flush is called. Usage is as follows.

stageInfo.x= gameData->getIntegerForKey("stageInfo_x");

See also

Favorite site