zoukankan      html  css  js  c++  java
  • CCUserDefault 存档

    void HelloWorld::testCCUserDefault()
    {
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        CCLabelTTF* ttf = CCLabelTTF::create(" ", "Helvetica", 30);
        ttf->setPosition(ccp(size.width/2, size.height/2));
        addChild(ttf);
    
        if (CCUserDefault::sharedUserDefault()->getBoolForKey("bool",false))
        {
            ttf->setString("No user data");
            //Load
            bool isBool = CCUserDefault::sharedUserDefault()->getBoolForKey("bool", false);
            double isDouble = CCUserDefault::sharedUserDefault()->getDoubleForKey("double", 0.0);
            float isFloat = CCUserDefault::sharedUserDefault()->getFloatForKey("float", 0.0f);
            int isInt = CCUserDefault::sharedUserDefault()->getIntegerForKey("int", 0);
            std::string isString = CCUserDefault::sharedUserDefault()->getStringForKey("string", "");
    
            CCLOG("%b__%d__%f__%f__%i__%s",isBool,isDouble,isFloat,isInt,isString.c_str());
    
        }else{
            ttf->setString("load user data");
    
            CCUserDefault::sharedUserDefault()->setBoolForKey("bool", true);
            CCUserDefault::sharedUserDefault()->setDoubleForKey("double", 998.0);
            CCUserDefault::sharedUserDefault()->setFloatForKey("float", 888.0f);
            CCUserDefault::sharedUserDefault()->setIntegerForKey("int", 88);
            CCUserDefault::sharedUserDefault()->setStringForKey("string", "Xff");
    
            //提交
            CCUserDefault::sharedUserDefault()->flush();
    
        }
        
    }

    生成文件  UserDefault.xml

  • 相关阅读:
    调用tensorflow中的concat方法时Expected int32, got list containing Tensors of type '_Message' instead.
    lstm公式推导
    RNN推导
    word2vec原理
    反向传播神经网络入门
    mac升级系统自带numpy失败解决方案
    mac安装.net core
    mac 当前位置打开终端
    docker安装配置
    KVM性能优化学习笔记
  • 原文地址:https://www.cnblogs.com/MrGreen/p/3308822.html
Copyright © 2011-2022 走看看