• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UserDefault类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: displayEnemy

void Picking::displayEnemy()
{
    auto fileU = FileUtils::getInstance();
    auto fileContent = fileU->getStringFromFile("data/animData.xml");
    doc.Parse(fileContent.c_str());

    UserDefault* def = UserDefault::getInstance();
    enemyMonster = def->getIntegerForKey(SaveDataKey[(n_DataKeyNum::eEnemyMonster01) + m_battleNum].c_str());

    auto sprite = doc.FirstChildElement()->FirstChildElement(MonsterNameData[enemyMonster].c_str());

    /*
    //CARD on the center
    m_enemySpecial = Sprite::create("img/UI/battle/UI_B_12.png");
    m_enemySpecial->setScale(m_Mag * 0.8);
    m_enemySpecial->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height - m_enemySpecial->getBoundingBox().getMaxY() * 0.75));
    m_instance->addChild(m_enemySpecial);
    m_enemySpecial->setVisible(false); //hidden for animation
    */

    //Monster Sprite number 2
    m_enemyCard = Sprite::create(sprite->FirstChildElement("spriteList")->FirstChildElement("animation")->FirstChildElement("stand")->GetText());
    m_enemyCard->setScale(m_Mag * 1.5);
    m_enemyCard->setPosition(Vec2((m_visibleSize.width / 6) * 4.5, m_visibleSize.height /2));
    m_instance->addChild(m_enemyCard);

}
开发者ID:riverreal,项目名称:MillionCode,代码行数:27,代码来源:PickingPhase.cpp


示例2: cleanAllEnemys

void InGameLayer::MenuBombCallback()
{
	SimpleAudioEngine::getInstance()->playEffect("sound/use_bomb.mp3");
	cleanAllEnemys();
	if(bombNum>0)
		bombNum--;

	auto label = static_cast<Label*>(this->getChildByTag(GameSceneNodeTagNumLabel));
	auto menu = static_cast<Menu*>(this->getChildByTag(GameSceneNodeTagMenuBomb));

	if (bombNum == 0)
	{
		label->setVisible(false);
		menu->setVisible(false);
	}
	else
	{
		label->setString(__String::createWithFormat("x%d",bombNum)->getCString());
	}
	score += 100;
	scoreLabel->setString(__String::createWithFormat("%d",score)->getCString());
	UserDefault *defaults = UserDefault::getInstance();
	int highScore = defaults->getIntegerForKey("highscore_key");    
	if (highScore < score) {
		highScore = score;
		defaults->setIntegerForKey("highscore_key", highScore);
	}
	__String *text = __String::createWithFormat("%i", highScore);

	auto lblScoreOfHigh = static_cast<Label*>(this->getChildByTag(GameSceneNodelblHighScore));
	lblScoreOfHigh->setString(text->getCString());
}
开发者ID:HeyUComeOn,项目名称:feijidazhan,代码行数:32,代码来源:InGameLayer.cpp


示例3: initData

void BBHandleLayer::initData()
{
    m_visibleSize = Director::getInstance()->getVisibleSize();
    
    m_blockLength = kBlockLength * BBGameDataManager::getInstance()->getScreenScale();
    
    m_row = 5;
    m_col = 4;
    
    m_countDown = 2;
    
    m_blockArr = Array::create();
    m_blockArr->retain();
    
    m_isReady = false;
    m_showTips = false;
    m_moves = 0;
    m_over = false;
    
    m_mixTimes = 100;
    m_blockAnimOver = true;
    m_idleBlockLastDirection = 0;
    m_curIndex = m_row * m_col + 1;
    
    UserDefault *ud = UserDefault::getInstance();
    if (ud->getBoolForKey("hasLocalData")) {
        m_moves = ud->getIntegerForKey("moves");
    }
}
开发者ID:fengzila,项目名称:BBMonalisa,代码行数:29,代码来源:BBHandleLayer.cpp


示例4: onPressMusic

void SettingsDialog::onPressMusic(cocos2d::Ref *sender, cocos2d::extension::Control::EventType pControlEvent)
{
	if (pControlEvent == Control::EventType::TOUCH_UP_INSIDE)
	{
        UserDefault *ud = UserDefault::getInstance();
        bool value = ud->getBoolForKey("music_enabled", true);
        ud->setBoolForKey("music_enabled", !value);
        
        if (value)
        {
            _checkBoxMusic->removeAllChildren();
            CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(false);
        }
        else
        {
            Label *l = Label::create();
            l->setString("X");
            l->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
            
            _checkBoxMusic->addChild(l);

            CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("playing.mp3", true);
        }
        
        ud->flush();
	}
}
开发者ID:eiji11,项目名称:clear-graffiti,代码行数:27,代码来源:SettingsDialog.cpp


示例5: GetNetBiosMacAddresses

const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
	std::string udid;
	UserDefault* userDefault = UserDefault::getInstance();
	if( NULL != userDefault )
	{
		udid = userDefault->getStringForKey( UDID_KEY );
	}
	if( udid.size() == 0 )
	{   
		//GUID uuid; 
		//CoCreateGuid(&uuid); 
		//// Spit the address out 
		//char mac_addr[18]; 
		//sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X", 
		//uuid.Data4[2],uuid.Data4[3],uuid.Data4[4], 
		//uuid.Data4[5],uuid.Data4[6],uuid.Data4[7]); 
		udid = GetNetBiosMacAddresses();
		if( userDefault )
		{
			userDefault->setStringForKey(UDID_KEY, udid);
            userDefault->flush();
		}
	}
	return udid;
}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:27,代码来源:CCNative.cpp


示例6: allCheck

int StageManager::allCheck(int id) {
	//id = 0 BRUE, id = 1 RED
	int brue, red;
	UserDefault* userdef = UserDefault::getInstance();
	brue = 0, red = 0;
	//BRUE
	if (id == 0) {
		for (int i = 0; i < m_Container.size(); ++i) {
			if (m_Container.at(i)->getColor() == Color3B::BLUE) {
				 ++brue;
				 userdef->setIntegerForKey("blue", brue);
			}
		}
		return brue;
	}
	//RED
	if (id == 1) {
		for (int i = 0; i < m_Container.size(); ++i) {
			if (m_Container.at(i)->getColor() == Color3B::RED) {
				++red;
				userdef->setIntegerForKey("red", red);
			}
		}
		return red;
	}
}
开发者ID:Proj-DDM,项目名称:GrimoArena,代码行数:26,代码来源:StageManager.cpp


示例7:

NS_CC_EXTRA_BEGIN
const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
	std::string udid;
	UserDefault* userDefault = UserDefault::getInstance();
	if( NULL != userDefault )
	{
		udid = userDefault->getStringForKey( UDID_KEY );
	}
	if( udid.size() == 0 )
	{
		//GUID guid = {0};
		//char szGuid[128]={0};
		//CoCreateGuid(&guid);
		//sprintf(szGuid, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
		//udid = "aaaaaaaaaaaaaaaaaaaa";
		udid = Application::getInstance()->getMacAddress();
		/// xx:xx:xx:xx:xx
		///一共有16位
		///4个冒号
		std::string::iterator end_pos = std::remove(udid.begin(), udid.end(), ' ');
		udid.erase(end_pos, udid.end()); 
		if( userDefault && udid.size() >= 16 )
		{
			userDefault->setStringForKey(UDID_KEY, udid);
		}
	}
	return udid;
}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:30,代码来源:CCNativeAndroid.cpp


示例8: textSelect

// テキストの設定
void resultText::textSelect()
{
    // スコアデータの取得
    UserDefault *userDef = UserDefault::getInstance();
    float tempScore = userDef->getIntegerForKey("Score", 0);
    
    int textRoot;
    score = tempScore;
    
    if (SCOREBORDER_1)
    {
        textRoot = 1;
    }
    else if (SCOREBORDER_2)
    {
        textRoot = 2;
    }
    else if (SCOREBORDER_3)
    {
        textRoot = 3;
    }
    else if (SCOREBORDER_4)
    {
        textRoot = 4;
    }
    else
    {
        textRoot = 5;
    }
    
    texts(textRoot);
}
开发者ID:unlimited02,项目名称:BackCoverCut2,代码行数:33,代码来源:ResultText.cpp


示例9: getStar

int BBGameDataManager::getStar(int themeId, int levelId)
{
    UserDefault* ud = UserDefault::getInstance();
    // 更新星级
    __String *starkey = __String::createWithFormat("star_%d_%d", themeId, levelId);
    return ud->getIntegerForKey(starkey->getCString(), 0);
}
开发者ID:fengzila,项目名称:bbPintu,代码行数:7,代码来源:BBGameDataManager.cpp


示例10: getBestTime

int BBGameDataManager::getBestTime(int themeId, int levelId)
{
    UserDefault* ud = UserDefault::getInstance();
    
    __String *bestkey = __String::createWithFormat("best_%d_%d", themeId, levelId);
    return ud->getIntegerForKey(bestkey->getCString(), 0);
}
开发者ID:fengzila,项目名称:bbPintu,代码行数:7,代码来源:BBGameDataManager.cpp


示例11: displayIcon

void Picking::displayIcon()
{
    auto fileU = FileUtils::getInstance();
    auto fileContent = fileU->getStringFromFile("data/animData.xml");

    UserDefault* def = UserDefault::getInstance();
    int key = def->getIntegerForKey(SaveDataKey[n_DataKeyNum::eMonsterData01 + m_battleNum].c_str());

    doc.Parse(fileContent.c_str());
    fileContent = fileU->getStringFromFile("data/monsterData.xml");
    mData.Parse(fileContent.c_str());

    m_HP = atoi(mData.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str())->FirstChildElement("HP")->GetText());
    auto sprite = doc.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str());


    key = def->getIntegerForKey(SaveDataKey[n_DataKeyNum::eEnemyMonster01 + m_battleNum].c_str());
    m_enemyHP = atoi(mData.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str())->FirstChildElement("HP")->GetText());


    //cut image to fit inside frame
    m_iconSprite = Sprite::create(sprite->FirstChildElement("spriteList")->FirstChildElement("animation")->FirstChildElement("stand")->GetText());
    m_iconSprite->setScale(m_Mag * 1.5);
    m_iconSprite->setPosition(Vec2((m_visibleSize.width / 6) * 1.8, m_visibleSize.height / 2));

    m_instance->addChild(m_iconSprite);
}
开发者ID:riverreal,项目名称:MillionCode,代码行数:27,代码来源:PickingPhase.cpp


示例12: cambiarSonido

void Ajustes::cambiarSonido(float positionX,bool fondo){
    float min = 0.0;
    float max = 0.0;
    if(!fondo){
        min = barraEfectos->getPositionX()-((barraEfectos->getContentSize().width*escala)/2);
        max = barraEfectos->getPositionX()+((barraEfectos->getContentSize().width*escala)/2);
    }else{
        min = barraMusica->getPositionX()-((barraMusica->getContentSize().width*escala)/2);
        max = barraMusica->getPositionX()+((barraMusica->getContentSize().width*escala)/2);
    }
    float maxOriginal = max-min;
    float valorOriginal = positionX-min;
    float porcentaje = (floorf((100*valorOriginal)/maxOriginal))/100;
    
    UserDefault *preferencias = UserDefault::getInstance();
    if(positionX>min&&positionX<max){
        if(!fondo){
            btEfectos->setPositionX(positionX);
            Configuracion::volumenEfectos = porcentaje;
            CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(Configuracion::volumenEfectos);
            preferencias->setFloatForKey("volEfectos", porcentaje);
        }else{
            btMusica->setPositionX(positionX);
            Configuracion::volumenMusica = porcentaje;
            CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(Configuracion::volumenMusica);
            preferencias->setFloatForKey("volMusica", porcentaje);
        }
    }
}
开发者ID:si2info,项目名称:info.si2.mostrosity,代码行数:29,代码来源:Ajustes.cpp


示例13: CC_CALLBACK_1

// on "init" you need to initialize your instance
bool GameOverScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

	auto backgroundSprite = Sprite::create("Background.png");
	backgroundSprite->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));

	this->addChild(backgroundSprite);

	auto retryItem = MenuItemImage::create("Retry Button.png", "Retry Button Clicked.png", CC_CALLBACK_1(GameOverScene::GoToGameScene, this));
	retryItem->setPosition(Point(visibleSize.width /2 + origin.x, visibleSize.height / 4 * 3));

	auto mainMenuItem = MenuItemImage::create("Menu Button.png", "Menu Button Clicked.png", CC_CALLBACK_1(GameOverScene::GoToMainMenuScene, this));
	mainMenuItem->setPosition(Point(visibleSize.width /2 + origin.x, visibleSize.height / 4 ));

	auto menu = Menu::create(retryItem, mainMenuItem, NULL);
	menu->setPosition(Point::ZERO);

	this->addChild(menu);

	UserDefault *def = UserDefault::getInstance();

	auto highScore = def->getIntegerForKey("HIGHSCORE", 0);

	if (score > highScore)
	{
		highScore = score;

		def->setIntegerForKey("HIGHSCORE", highScore);
	}

	def->flush();

	__String *tempScore = __String::createWithFormat("Current : %i", score);

	auto currentScore = LabelTTF::create(tempScore->getCString(), "fonts/Marker Felt.ttf", visibleSize.height * SCORE_FONT_SIZE);
	currentScore->setPosition(Point(visibleSize.width * 0.25 + origin.x, visibleSize.height /2 + origin.y ));

	this->addChild(currentScore);
	
	__String *temHighpScore = __String::createWithFormat("High : %i", highScore);

	auto highScoreLabel = LabelTTF::create(temHighpScore->getCString(), "fonts/Marker Felt.ttf", visibleSize.height * SCORE_FONT_SIZE);

	highScoreLabel->setColor(Color3B::YELLOW);
	highScoreLabel->setPosition(Point(visibleSize.width * 0.75 + origin.x, visibleSize.height / 2 + origin.y));

	this->addChild(highScoreLabel);

	return true;
}
开发者ID:StartNewLife,项目名称:FlappyBird,代码行数:60,代码来源:GameOverScene.cpp


示例14: registerCurrentScore

void HighScoreManager::registerCurrentScore(int score)
{
    UserDefault* userDef = UserDefault::getInstance();
    if (score > userDef->getIntegerForKey(KEY_HIGHSCORE.c_str(), 0))
    {
        userDef->setIntegerForKey(KEY_HIGHSCORE.c_str(), score);
    }
}
开发者ID:IIJAN2016,项目名称:FlappyBird,代码行数:8,代码来源:HighScoreManager.cpp


示例15: showReviewAlertWhenOpenTime

void ThirdPartyHelper::showReviewAlertWhenOpenTime(int opentime){
    UserDefault *ud = UserDefault::getInstance();
    int cu = ud->getIntegerForKey(LHOPENTIME, 0);
    cu ++;
    ud->setIntegerForKey(LHOPENTIME, cu);
    if (cu == opentime) {
        ThirdPartyHelper::showReviewAlert();
    }
}
开发者ID:LuckyGameCn,项目名称:LHCocosGame,代码行数:9,代码来源:ThirdPartyHelper.cpp


示例16: displayText

// テキストの表示
void resultText::displayText()
{
    // 保存データの読み込み
    UserDefault *userDef = UserDefault::getInstance();
    
    float angle = userDef->getFloatForKey("scoreAngle", 0);
    float resultAngle = angle;
    
    if ( resultAngle < 0 )
    {
        resultAngle = resultAngle * (-1);
    }
    
    float distance = userDef->getFloatForKey("scoreDistance", 0);
    float resultDistance = distance;
    
    // 角度表示
    Label *viewAngle = Label::createWithSystemFont("a", "Arial", 50);
    viewAngle->setPosition(WINSIZE.width/2, WINSIZE.height/1.2);
    addChild(viewAngle);
    
    viewAngle->setString(StringUtils::format("角度:%0.2f°", resultAngle));
    log("%0.2f°",resultAngle);
    
    // 距離表示
    Label *viewPixel = Label::createWithSystemFont("", "Arial", 50);
    viewPixel->setPosition(WINSIZE.width/2, WINSIZE.height/1.37);
    addChild(viewPixel);
    
    viewPixel->setString(StringUtils::format("背表紙のりまでの間隔:%0.2fピクセル", resultDistance));
    log("%0.2fピクセル", resultDistance);
    
    // 点数表示
    Label *viewScore = Label::createWithSystemFont("", "Arial", 50);
    viewScore->setPosition(WINSIZE.width/2, WINSIZE.height/1.6);
    addChild(viewScore);

    viewScore->setString(StringUtils::format("点数:%ld", score));
    
    // 評価文章表示
    Label *viewText1 = Label::createWithSystemFont(arrayText[0], "Arial", 27);
    viewText1->setPosition(WINSIZE.width/2, 300);
    addChild(viewText1);

    Label *viewText2 = Label::createWithSystemFont(arrayText[1], "Arial", 27);
    viewText2->setPosition(WINSIZE.width/2, 250);
    addChild(viewText2);
    
    Label *viewText3 = Label::createWithSystemFont(arrayText[2], "Arial", 27);
    viewText3->setPosition(WINSIZE.width/2, 200);
    addChild(viewText3);
    
    viewText1->setString(StringUtils::format("プロジェクトマネージャー...%s", arrayText[0].c_str()));
    viewText2->setString(StringUtils::format("慇懃無礼な商人...%s", arrayText[1].c_str()));
    viewText3->setString(StringUtils::format("C...%s", arrayText[2].c_str()));
    log("ラベル配置");
}
开发者ID:unlimited02,项目名称:BackCoverCut2,代码行数:58,代码来源:ResultText.cpp


示例17: log

void PlaySceneOne::onEnterTransitionDidFinish()
{
	Layer::onEnterTransitionDidFinish();
	log("GamePlayLayer onEnterTransitionDidFinish");
	UserDefault *defaults = UserDefault::getInstance();
	if (defaults->getBoolForKey(MUSIC_KEY)) {
		SimpleAudioEngine::getInstance()->playBackgroundMusic(bg_music_2, true);
	}
}
开发者ID:MulticsYin,项目名称:Archer-cocos2d-x,代码行数:9,代码来源:PlaySceneOne.cpp


示例18: setSprite

void NegiSprite::setSprite()
{
    this->setPosition(Vec2(WINSIZE.width/2, WINSIZE.height/2));
    
    float setLine = 3.0;
    
    UserDefault *userDef = UserDefault::getInstance();
    userDef->setFloatForKey("SetLine", setLine);
    userDef->flush();
}
开发者ID:unlimited02,项目名称:BackCoverCut2,代码行数:10,代码来源:Negi.cpp


示例19: menuSoundToggleCallback

void SettingLayer::menuSoundToggleCallback(Ref* pSender)
{
	UserDefault *defaults  = UserDefault::getInstance();
	if (defaults->getBoolForKey(SOUND_KEY)) {
		defaults->setBoolForKey(SOUND_KEY, false);
	} else {
		defaults->setBoolForKey(SOUND_KEY, true);
		SimpleAudioEngine::getInstance()->playEffect(sound_1);
	}
}
开发者ID:bluecain,项目名称:MyLostRoutes,代码行数:10,代码来源:SettingScene.cpp


示例20: menuMusicToggleCallback

void SettingLayer::menuMusicToggleCallback(Ref* pSender)
{
	UserDefault *defaults  = UserDefault::getInstance();
	if (defaults->getBoolForKey(MUSIC_KEY)) {
		defaults->setBoolForKey(MUSIC_KEY, false);
		SimpleAudioEngine::getInstance()->stopBackgroundMusic();
	} else {
		defaults->setBoolForKey(MUSIC_KEY, true);
		SimpleAudioEngine::getInstance()->playBackgroundMusic(bg_music_2, true);
	}
}
开发者ID:bluecain,项目名称:MyLostRoutes,代码行数:11,代码来源:SettingScene.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UserGenerator类代码示例发布时间:2022-05-31
下一篇:
C++ UserData类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap