当前位置: 首页>>代码示例>>C++>>正文


C++ CCUserDefault类代码示例

本文整理汇总了C++中CCUserDefault的典型用法代码示例。如果您正苦于以下问题:C++ CCUserDefault类的具体用法?C++ CCUserDefault怎么用?C++ CCUserDefault使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCUserDefault类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setAndroidHDEnabled

void GameConfig::setAndroidHDEnabled(bool val)
{
    mEnableAndroidHD = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_ANDROID_HD_KEY, mEnableAndroidHD);
    user->flush();
}
开发者ID:Geminichel,项目名称:ph-open,代码行数:7,代码来源:Common.cpp

示例2: setMute

void Config::setMute(bool mute) {
	m_mute = mute;
	CCUserDefault* ud = CCUserDefault::sharedUserDefault();
	ud->setBoolForKey(CONFIG_KEY_MUTE, m_mute);
	if (m_mute)
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects();
}
开发者ID:Asheng321,项目名称:PopStar,代码行数:7,代码来源:Config.cpp

示例3: loadEffectiveItems

void
MCBackpack::loadData()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    
    loadEffectiveItems();
    
    if (! __icon_loaded) {
        loadIcons();
    }
    
    if (MCGameState::sharedGameState()->isSaveFileExists()) {
        string data = userDefault->getStringForKey(kMCBackpackKey, kMCZero);
        if (data.size() > 0) {
#if MC_DEBUG_SAVEDATA == 1
            const char *output = data.c_str();
#else
            const char *input = data.c_str();
            char *output;
            mc_size_t len = strlen(input);
            MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
            JsonBox::Value v;
            v.loadFromString(output);
            
            JsonBox::Object backpack = v.getObject();
            /* 加载金钱 */
            money_ = backpack[kMCMoneyKey].getInt();
        }
    } else {
        money_ = 0;
    }
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:33,代码来源:MCBackpack.cpp

示例4: setTutorialProgress

void GameConfig::setTutorialProgress(PH::TutorialProgress progress)
{
    tutorialMode = progress;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setIntegerForKey(CONFIG_TUTORIAL_PROGRESS, tutorialMode);
    user->flush();
}
开发者ID:Geminichel,项目名称:ph-open,代码行数:7,代码来源:Common.cpp

示例5: addChild

bool LevelScene::init()
{
    SkyLayer *pSkyLayer = SkyLayer::create();
    addChild(pSkyLayer);
    
    createLevelsLayer();
    
    CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("back.png");
    SpriteButton *pBackButton = SpriteButton::create(pTexture, this, callfuncO_selector(LevelScene::backClicked));
    CCPoint bottomLeft = VisibleRect::leftBottom();
    pBackButton->setPosition(ccp(bottomLeft.x + 70, bottomLeft.y + 60));
    addChild(pBackButton);
    
    //Read preferences
    CCUserDefault *pUserDefaults = CCUserDefault::sharedUserDefault();
    
    float volume = pUserDefaults->getFloatForKey("volume");
    bool sound = pUserDefaults->getBoolForKey("sound");
    
    if (sound) {
        bool isPlaying = SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying();
        
        if (!isPlaying)
            SimpleAudioEngine::sharedEngine()->playBackgroundMusic("sounds/music.wav", true);
        
        SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(volume);
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(volume);
    }
    
    return true;
}
开发者ID:ikermendi,项目名称:Ikasitz,代码行数:31,代码来源:LevelScene.cpp

示例6:

/**
 * 清除数据
 */
void
MCTaskAccessor::erase()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    
    userDefault->setStringForKey(kMCTasksKey, "");
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:10,代码来源:MCTaskAccessor.cpp

示例7: setSFXEnabled

void GameConfig::setSFXEnabled(bool val)
{
    mEnableSFX = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_SFX_KEY, mEnableSFX);
    user->flush();
}
开发者ID:Geminichel,项目名称:ph-open,代码行数:7,代码来源:Common.cpp

示例8: setBGMEnabled

void GameConfig::setBGMEnabled(bool val)
{
    mEnableBGM = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_BGM_KEY, mEnableBGM);
    user->flush();
}
开发者ID:Geminichel,项目名称:ph-open,代码行数:7,代码来源:Common.cpp

示例9: backpackValue

void
MCBackpack::saveData()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    
    saveEffectiveItems();
    
    JsonBox::Object backpack;
    
    /* 储存金钱 */
    backpack[kMCMoneyKey] = JsonBox::Value(money_);
    
    JsonBox::Value backpackValue(backpack);
    ostringstream outputStream;
    backpackValue.writeToStream(outputStream);
    string data = outputStream.str();
#if MC_DEBUG_SAVEDATA == 1
    const char *output = data.c_str();
#else
    const char *input = data.c_str();
    char  *output;
    mc_size_t len = strlen(input);
    MCBase64Encode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
    userDefault->setStringForKey(kMCBackpackKey, output);
#if MC_DEBUG_SAVEDATA != 1
    delete []output;
#endif
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:29,代码来源:MCBackpack.cpp

示例10: saveBasic

void Memory::saveBasic()
{
    CCUserDefault * def = CCUserDefault::sharedUserDefault();
    
//    Json::Value val(Json::ValueType::objectValue);
//    val["accountId"] = _accountId;
//    val["password"] = _passwordHashed;
//    val["lastServerId"] = _lastServerId;
//    val["musicOn"] = _musicOn;
//    val["effectOn"] = _effectOn;
//
//    
//    Json::Value val2(Json::ValueType::arrayValue);
//    for (auto tr:_pendingTransactions)
//    {
//        Json::Value val3(Json::ValueType::objectValue);
//        val3["p"] = tr.productId;
//        val3["t"] = tr.transactionId;
//        val3["r"] = tr.receipt;
//
//        val2[val2.size()] = val3;
//    }
//    val["pendingTransactions"] = val2;
    
    
//    def->setStringForKey("Memory_basic", SSTR(val));
    def->flush();
}
开发者ID:xu561865,项目名称:demo_2,代码行数:28,代码来源:Memory.cpp

示例11: onClickedLogin

void LoginLayer::onClickedLogin(CCObject *sender, TouchEventType event)
{
    if (event == TOUCH_EVENT_ENDED)
    {
        SimpleAudioEngine::sharedEngine()->playEffect(BUTTON_CLICK);
        
        _msg->setText("");
        LoginMeg tmpMeg;
        tmpMeg.name = _account->getText();
        tmpMeg.pwd = _password->getText();
        
        if (tmpMeg.name.empty())
        {
            _msg->setText("请输入联众账号!");
            return;
        }
        
        if (tmpMeg.pwd.empty())
        {
            _msg->setText("请输入账号密码!");
            return;
        }
        
        CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
        userDefault->setStringForKey(SAVE_H_ACCOUNT, tmpMeg.name);
        userDefault->setStringForKey(SAVE_H_PASSWORD, tmpMeg.pwd);
        userDefault->flush();
        
        CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_LOGIN2MEG, &tmpMeg);
    }
}
开发者ID:mrktj,项目名称:SlotGame,代码行数:31,代码来源:LoginLayer.cpp

示例12:

KDvoid Ch3_SavingSimpleData::saveDifficulty ( KDvoid )
{
	// Save our difficulty
	CCUserDefault*		pDefaults = CCUserDefault::sharedUserDefault ( );

	pDefaults->setStringForKey ( "simple_data_difficulty", m_sDifficulty.c_str ( ) );
	pDefaults->flush ( );
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:8,代码来源:Ch3_SavingSimpleData.cpp

示例13: menu_selector

bool MainScene::init()
{
	CCSize winSize = Director::getInstance()->getVisibleSize();
	if (!CCLayer::init())
	{
		return false;
	}
	auto BackGround = Sprite::create("backg.png");
	BackGround->setPosition(ccp(winSize.width / 2, winSize.height / 2)); //위치지정
	this->addChild(BackGround);

	CCMenu *MenuMain = CCMenu::create(NULL); //메뉴생성
	CCMenu *MenuMain1 = CCMenu::create(NULL); //메뉴생성
	CCMenu *MenuMain2 = CCMenu::create(NULL); //메뉴생성

	//메뉴아이템 추가
	CCMenuItem *item1 = CCMenuItemImage::create("start.png",
		"start.png",
		this,
		menu_selector(MainScene::menuCloseCallback));
	CCMenuItem *item2 = CCMenuItemImage::create("rank.png",
		"rank.png",
		this,
		menu_selector(MainScene::RankCloseCallback));

	CCMenuItem *item3 = CCMenuItemImage::create("create.png",
		"create.png",
		this,
		menu_selector(MainScene::CreaterMenuCallback));


	MenuMain->addChild(item1, 1); //메뉴에 아이템 붙이기
	MenuMain1->addChild(item2, 2);
	MenuMain2->addChild(item3, 3);

	MenuMain->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 20));
	MenuMain1->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 90));
	MenuMain2->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 160));

	this->addChild(MenuMain, 1);
	this->addChild(MenuMain1, 2);
	this->addChild(MenuMain2, 3);//메뉴를 레이어에 추가

	CCUserDefault* user = CCUserDefault::sharedUserDefault();
	int SaveSw = CCUserDefault::sharedUserDefault()->getIntegerForKey("SaveMake");
	if (SaveSw == 0){
		user->setIntegerForKey("SaveMake", 1);
		user->setIntegerForKey("Rank1", 0);
		user->setIntegerForKey("Rank2", 0);
		user->setIntegerForKey("Rank3", 0);
		user->setIntegerForKey("Rank4", 0);
		user->setIntegerForKey("Rank5", 0);
	}

	return true;
}
开发者ID:kmu9842,项目名称:Jeweljewel,代码行数:56,代码来源:MainScene.cpp

示例14: initStore

void CCNative::initStore(CCDictionary* dict)
{
	CCArray* keys = dict->allKeys();
	CCObject* key;
	CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
	CCARRAY_FOREACH(keys, key)
	{
		const char* keyStr = ((CCString*)key)->getCString();
		userDefault->setStringForKey(keyStr, dict->valueForKey(keyStr)->getCString());
	}
}
开发者ID:liyonghelpme,项目名称:iosdifferentbranchcode,代码行数:11,代码来源:CCNative.cpp

示例15: soundsButtonTapped

void  PauseLayer::soundsButtonTapped(CCObject *sender) {
    CCUserDefault *defaults = CCUserDefault::sharedUserDefault();
    CCMenuItemToggle *toggleItem = (CCMenuItemToggle*)sender;
    if (toggleItem->selectedItem() == menuItemSoundOn) {
        defaults->setBoolForKey(kSoundsKey, true);
        Utility::changeVolume(1.0f);
    } else if (toggleItem->selectedItem() == menuItemSoundOff) {
        defaults->setBoolForKey(kSoundsKey, false);
        Utility::changeVolume(0.0f);
    }
}
开发者ID:ashtonjohnson,项目名称:testing_games,代码行数:11,代码来源:PauseLayer.cpp


注:本文中的CCUserDefault类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。