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


C++ UserDefault类代码示例

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


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


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