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呢?程序员: 那我将永远无法完成任务.

  • 相关阅读:
    个人介绍
    C++ 之 第四课 C++中的运算符、表达式
    Delphi 之 第六课 过程与函数
    Delphi 之 第五课 流程语句
    VB 之 第三课 VB API 字体函数的应用
    C++ 之 第三课 C++数据类型
    Delphi 之 第四讲 自定义数据类型
    Delphi 之 第三课 详解数据类型
    C++ 之 第二课 C++类、函数的讲解
    VB API 第二课 之 字符串大小写转换
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3023931.html
Copyright © 2011-2022 走看看