当前位置:网站首页>Cocos2d-x game archive [easy to understand]
Cocos2d-x game archive [easy to understand]
2022-07-07 20:45:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
The game archive function can save the data in the game . Let players continue the game . Single game is more important . and CCUserDefault It can be used as a lightweight database , Used to store data , Support data types bool,int, float, double, string.
Store the data
CCUserDefault::sharedUserDefault()->setStringForKey("string", "value1"); // Parameter order : key . The corresponding value
CCUserDefault::sharedUserDefault()->setIntegerForKey("integer", 10);
CCUserDefault::sharedUserDefault()->setFloatForKey("float", 2.3f);
CCUserDefault::sharedUserDefault()->setDoubleForKey("double", 2.4);
CCUserDefault::sharedUserDefault()->setBoolForKey("bool", true);Get the above data output
string str = CCUserDefault::sharedUserDefault()->getStringForKey("string");// Parameters : Return key value according to the passed in key
CCLOG("str: %s", str.c_str());
int i = CCUserDefault::sharedUserDefault()->getIntegerForKey("integer");
CCLOG("i: %d", i);
float f = CCUserDefault::sharedUserDefault()->getFloatForKey("float");
CCLOG("f: %f", f);
double d = CCUserDefault::sharedUserDefault()->getDoubleForKey("double");
CCLOG("d: %f", d);
bool b = CCUserDefault::sharedUserDefault()->getBoolForKey("bool");
if (b)
CCLOG("bool is true");
else
CCLOG("bool is false");Change data
CCUserDefault::sharedUserDefault()->setStringForKey("string", "test"); // changes string data
CCUserDefault::sharedUserDefault()->setFloatForKey("float", 3.1413); // changes float data
string str1 = CCUserDefault::sharedUserDefault()->getStringForKey("string");
CCLOG("str1: %s", str1.c_str());
float f2 =CCUserDefault::sharedUserDefault()->getFloatForKey("float");
CCLOG("f2: %f", f2);Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116383.html Link to the original text :https://javaforall.cn
边栏推荐
- POJ 1742 coins (monotone queue solution) [suggestions collection]
- Data sorting in string
- 写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
- ISO 26262 - 基于需求测试以外的考虑因素
- JNI 初级接触
- 使用高斯Redis实现二级索引
- Measure the height of the building
- Tensorflow2. How to run under x 1 Code of X
- 部署、收回和删除解决方式—-STSADM和PowerShell「建议收藏」
- Postgresql数据库character varying和character的区别说明
猜你喜欢

Static analysis of software defects codesonar 5.2 release

C语言 整型 和 浮点型 数据在内存中存储详解(内含原码反码补码,大小端存储等详解)

95年专注安全这一件事 沃尔沃未来聚焦智能驾驶与电气化领域安全

AADL Inspector 故障树安全分析模块

Nebula Importer 数据导入实践

Measure the height of the building

Implement secondary index with Gaussian redis

Micro service remote debug, nocalhost + rainbow micro service development second bullet

Apifox interface integrated management new artifact

OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
随机推荐
Klocwork 代码静态分析工具
如何满足医疗设备对安全性和保密性的双重需求?
反诈困境,国有大行如何破局?
FTP steps for downloading files from Huawei CE switches
Intelligent software analysis platform embold
object-c编程tips-timer「建议收藏」
寫一下跳錶
凌云出海记 | 易点天下&华为云:推动中国电商企业品牌全球化
Introduction to referer and referer policy
目前股票开户安全吗?可以直接网上开户吗。
guava多线程,futurecallback线程调用不平均
JNI 初级接触
神兵利器——敏感文件发现工具
openGl超级宝典学习笔记 (1)第一个三角形「建议收藏」
Network principle (1) - overview of basic principles
How to meet the dual needs of security and confidentiality of medical devices?
如何满足医疗设备对安全性和保密性的双重需求?
最新版本的CodeSonar改进了功能安全性,支持MISRA,C ++解析和可视化
智能交通焕发勃勃生机,未来会呈现哪些巨变?[通俗易懂]
Write a jump table