当前位置:网站首页>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
边栏推荐
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- 权限不足
- MySQL约束之默认约束default与零填充约束zerofill
- 不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
- [concept of network principle]
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- Onespin | solve the problems of hardware Trojan horse and security trust in IC Design
- Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance
- Jenkins 用户权限管理
- How to meet the dual needs of security and confidentiality of medical devices?
猜你喜欢

H3C s7000/s7500e/10500 series post stack BFD detection configuration method

Small guide for rapid formation of manipulator (11): standard nomenclature of coordinate system

Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system

让这个CRMEB单商户微信商城系统火起来,太好用了!
![Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]](/img/af/61b384b1b6ba46aa1a6011f8a30085.png)
Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]

H3C S7000/S7500E/10500系列堆叠后BFD检测配置方法

复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算

Airiot helps the urban pipe gallery project, and smart IOT guards the lifeline of the city

ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your

测量楼的高度
随机推荐
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
Ubuntu安装mysql8遇到的问题以及详细安装过程
Measure the height of the building
凌云出海记 | 赛盒&华为云:共助跨境电商行业可持续发展
Apifox 接口一体化管理新神器
Airiot helps the urban pipe gallery project, and smart IOT guards the lifeline of the city
Numerical method for solving optimal control problem (0) -- Definition
部署、收回和删除解决方式—-STSADM和PowerShell「建议收藏」
开发一个小程序商城需要多少钱?
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System
恢复持久卷上的备份数据
When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
如何满足医疗设备对安全性和保密性的双重需求?
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
Mysql子查询关键字的使用方式(exists)
使用高斯Redis实现二级索引
反诈困境,国有大行如何破局?
Small guide for rapid formation of manipulator (11): standard nomenclature of coordinate system
4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance