zoukankan      html  css  js  c++  java
  • 设置、数值【Cocos2DX 】初窥门径(11)CCUserDefault:保存数据by小雨

    在写这篇文章之前,xxx已经写过了几篇关于改设置、数值-主题的文章,想要了解的朋友可以去翻一下之前的文章

        保存单简的数据用CCUserDefault和Android中的SharedPreferences一样,都是以键值对存储的。

        

    //获得bool型值
     bool getBoolForKey(const char* pKey, bool defaultValue = false);
     //获得整型值
     int  getIntegerForKey(const char* pKey, int defaultValue = 0);
    //获得浮点数值
     float getFloatForKey(const char* pKey, float defaultValue=0.0f);
     //获得双精度浮点数值
     double  getDoubleForKey(const char* pKey, double defaultValue=0.0);
    //获得字符串
     std::string getStringForKey(const char* pKey, const std::string & defaultValue = "");
     
     
    //设置尔布型值
    void setBoolForKey(const char* pKey, bool value);
     //设置整型值
     void setIntegerForKey(const char* pKey, int value);
     //设置浮点数值
     void setFloatForKey(const char* pKey, float value);
     //双精度浮点数值
     void setDoubleForKey(const char* pKey, double value);
     //设置字符串值
     void setStringForKey(const char* pKey, const std::string & value);

        用法:

    CCUserDefault::sharedUserDefault()->setStringForKey("UserName","henn");

        

        

        载转请注明出处:http://blog.csdn.net/Vestigge

        

        

        

    文章结束给大家分享下程序员的一些笑话语录: 开发时间
      项目经理: 如果我再给你一个人,那可以什么时候可以完工?程序员: 3个月吧!项目经理: 那给两个呢?程序员: 1个月吧!
    项目经理: 那100呢?程序员: 1年吧!
    项目经理: 那10000呢?程序员: 那我将永远无法完成任务.

  • 相关阅读:
    Android开发探秘之一:创建可以点击的Button
    TCP之心跳包实现思路
    Asp.net与Dojo交互:仪器仪表实现
    Asp.net Json数据解析的一种思路
    Asp.net通过Jquery操作WebService进行Ajax读写
    GridView自定义删除操作
    从客户端中检测到有潜在危险的request.form值
    JUC-Condition线程通信
    ModelAndView 配置与使用
    SpringMVC之ModelAndView的用法(转)
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3023931.html
Copyright © 2011-2022 走看看