本文整理汇总了C++中CCUserDefault::getBoolForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CCUserDefault::getBoolForKey方法的具体用法?C++ CCUserDefault::getBoolForKey怎么用?C++ CCUserDefault::getBoolForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCUserDefault
的用法示例。
在下文中一共展示了CCUserDefault::getBoolForKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void Config::load() {
CCUserDefault* ud = CCUserDefault::sharedUserDefault();
m_mute = ud->getBoolForKey(CONFIG_KEY_MUTE);
m_hasSavedPuzzle = ud->getBoolForKey(CONFIG_KEY_HASSAVEDPUZZLE);
m_highScore = ud->getIntegerForKey(CONFIG_KEY_HIGHSCORE);
m_highLevel = ud->getIntegerForKey(CONFIG_KEY_HIGHLEVEL);
if (m_hasSavedPuzzle) {
m_savedScore = ud->getIntegerForKey(CONFIG_KEY_SAVEDSCORE);
m_savedTarget = ud->getIntegerForKey(CONFIG_KEY_SAVEDTARGET);
m_savedLevel = ud->getIntegerForKey(CONFIG_KEY_SAVEDLEVEL);
m_savedRow = ud->getIntegerForKey(CONFIG_KEY_SAVEDROW);
m_savedCol = ud->getIntegerForKey(CONFIG_KEY_SAVEDCOL);
m_savedPuzzle = ud->getStringForKey(CONFIG_KEY_SAVEDPUZZLE);
}
}
示例2: readLocalDataToRunTime
void LocalData::readLocalDataToRunTime()
{
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
RunTimeData::getInstance()->hasMusic = userDefault->getBoolForKey("hasmusic", true);
std::string levelStr = userDefault->getStringForKey("levelStarStr", "");
RunTimeData::getInstance()->passedLevel = userDefault->getIntegerForKey("passedLevelNum", 1);
RunTimeData::getInstance()->startNum = userDefault->getIntegerForKey("totalStarNum", 0);
RunTimeData::getInstance()->annihilatorNum = userDefault->getIntegerForKey("annihilator", 0);
RunTimeData::getInstance()->isFirstTime = userDefault->getBoolForKey("isFirstTime", true);
if (levelStr.length() != 0){
strcpy(RunTimeData::getInstance()->levelStars, levelStr.c_str());
}
RunTimeData::getInstance()->isFirstTime = userDefault->getBoolForKey("guiderecord", true);
}
示例3: init
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;
}
示例4: OnSceneChangedToAppear
void MainScene::OnSceneChangedToAppear()
{
// Audio Setting
GooRoomClient& client = GooRoomClient::Instance();
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
client.SetBGMOn(userDefault->getBoolForKey("IsBGMOn", true));
client.SetEffectOn(userDefault->getBoolForKey("IsEffectOn", true));
client.SetMessageOn(userDefault->getBoolForKey("IsMessageOn", true));
const float bgmVolume = GooRoomClient::Instance().IsBGMOn() ? BGM_SOUND_NORMAL : 0.f;
AudioEngine::Instance()->SetBackgroundVolume(bgmVolume);
const float effectVolume = GooRoomClient::Instance().IsEffectOn() ? 0.9f : 0.f;
AudioEngine::Instance()->SetEffectVolume(effectVolume);
// End Autio Setting
AudioEngine::Instance()->PlayBackgroundMusic("bgm/mainScene.mp3");
}
示例5: shared
GameConfig* GameConfig::shared()
{
static GameConfig* config = NULL;
if(config == NULL)
{
config = new GameConfig();
CCUserDefault* user = CCUserDefault::sharedUserDefault();
config->tutorialMode = (TutorialProgress)user->getIntegerForKey(CONFIG_TUTORIAL_PROGRESS, TutorialSkip);
config->mEnableSFX = user->getBoolForKey(CONFIG_SFX_KEY, true);
config->mEnableBGM = user->getBoolForKey(CONFIG_BGM_KEY, true);
config->mEnableAndroidHD = user->getBoolForKey(CONFIG_ANDROID_HD_KEY, false);
config->stageTab = -1;
config->stageId = -1;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
config->useTouchSmooth = true;
#else
config->useTouchSmooth = false;
#endif
}
return config;
}
示例6: init
bool MenuScene::init()
{
SkyLayer *pSkyLayer = SkyLayer::create();
addChild(pSkyLayer);
CCRect visibleRect = VisibleRect::getVisibleRect();
CCSprite *pLogo = CCSprite::create("logo.png");
pLogo->setPosition(VisibleRect::center());
addChild(pLogo);
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("play.png");
pPlayButton = SpriteButton::create(pTexture, this, callfuncO_selector(MenuScene::playClicked));
pPlayButton->setPosition(ccp(477, 185));
addChild(pPlayButton);
pTexture = CCTextureCache::sharedTextureCache()->addImage("about.png");
pInfoButton = SpriteButton::create(pTexture, this, callfuncO_selector(MenuScene::infoClicked));
pInfoButton->setPosition(ccp(visibleRect.origin.x + 205, visibleRect.origin.y + 60));
addChild(pInfoButton);
pTexture = CCTextureCache::sharedTextureCache()->addImage("settings.png");
pSettingsButton = SpriteButton::create(pTexture, this, callfuncO_selector(MenuScene::settingsClicked));
pSettingsButton->setPosition(ccp(visibleRect.origin.x + 110, visibleRect.origin.y + 60));
addChild(pSettingsButton);
//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;
}
示例7: load
void GameConfig::load()
{
std::string playerUID = PlayerData::getInstance()->player->uid;
CCUserDefault* user = CCUserDefault::sharedUserDefault();
showInstanceStage = user->getBoolForKey((playerUID + "_instance_stage").c_str(),
false);
showSoulExchange = user->getBoolForKey((playerUID + "_soul_exchange").c_str(),
false);
showShuffleRelation = user->getBoolForKey((playerUID + "_shuffle_relation").c_str(), false);
firstTimeNeili = user->getBoolForKey((playerUID + "_first_time_neili").c_str(), true);
firstTimeShowInstance = user->getBoolForKey((playerUID + "_first_time_instance").c_str(), true);
firstTimeZhuansheng = user->getBoolForKey((playerUID + "_first_time_zhuansheng").c_str(), true);
openInstanceStep = user->getIntegerForKey((playerUID + "_open_instance").c_str(), 0);
openJueDing10 = user->getBoolForKey((playerUID + "_open_jueding10").c_str(), false);
showDragHint = user->getBoolForKey((playerUID + "_show_drag_hint").c_str(), true);
showAttrHint = user->getBoolForKey((playerUID + "_show_attr_hint").c_str(), true);
}
示例8: load
bool GameData::load()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
CCUserDefault* read = CCUserDefault::sharedUserDefault();
_isExisted = read->getBoolForKey("IsExisted");
if (!_isExisted) {
return false;
}
_highScore = read->getIntegerForKey("HighScore");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
_isExisted = JNI_getBool("IsExisted", false);
if (!_isExisted) {
return false;
}
_highScore = JNI_getInt("HighScore", 0);
#endif
return true;
}
示例9: load
bool GameData::load()
{
#if (ANDROIDSAVEBYUSERDEFAULT == 1 && CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
gd_isBeginner = JNI_getBool("IsBeginner", true);
if (gd_isBeginner) {
return false;
}
gd_highScore = JNI_getInt("HighScore", 0);
gd_gold = JNI_getInt("Gold", 0);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCUserDefault* read = CCUserDefault::sharedUserDefault();
gd_isBeginner = read->getBoolForKey("IsBeginner", true);
if (gd_isBeginner) {
return false;
}
gd_highScore = read->getIntegerForKey("HighScore", 0);
gd_gold = read->getIntegerForKey("Gold", 0);
#endif
return true;
}
示例10: init
bool TitleScene::init()
{
//debug
this->debugBoot = false;
// 初期化色を変更
if (!CCLayerColor::initWithColor(ccc4(0xFF,0xEF,0xFF,0xFF))) //RGBA
{
return false;
}
//GameCenterにログイン
Cocos2dExt::NativeCodeLauncher::loginGameCenter();
//一回もクリアしたことなければチュートリアル表示
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
string tutorialKey = ConstCommon::getTutorialKey();
this->firstTimeGame = ! userDefault->getBoolForKey(tutorialKey.c_str());
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* pA = CCSprite::create("logo_A.png");
float originSize = ((size.width * 0.937) / 6) / pA->getContentSize().width;
pA->setPosition(ccp(size.width * 0.1, size.height * 0.8));
//pA->setScale(0.6);
pA->setScale(originSize);
pA->runAction(Animation::titleCharaAction(originSize));
this->addChild(pA);
CCSprite* pR = CCSprite::create("logo_R.png");
pR->setPosition(ccp(size.width * 0.26, size.height * 0.8));
//pR->setScale(0.6);
pR->setScale(originSize);
pR->runAction(CCSequence::create(CCDelayTime::create(0.05),Animation::titleCharaAction(originSize),NULL));
this->addChild(pR);
CCSprite* pR2 = CCSprite::create("logo_R.png");
pR2->setPosition(ccp(size.width * 0.42, size.height * 0.8));
//pR2->setScale(0.6);
pR2->setScale(originSize);
pR2->runAction(CCSequence::create(CCDelayTime::create(0.1),Animation::titleCharaAction(originSize),NULL));
this->addChild(pR2);
CCSprite* pO = CCSprite::create("logo_O.png");
pO->setPosition(ccp(size.width * 0.58, size.height * 0.8));
//pO->setScale(0.6);
pO->setScale(originSize);
pO->runAction(CCSequence::create(CCDelayTime::create(0.15),Animation::titleCharaAction(originSize),NULL));
this->addChild(pO);
CCSprite* pW = CCSprite::create("logo_W.png");
pW->setPosition(ccp(size.width * 0.74, size.height * 0.8));
//pW->setScale(0.6);
pW->setScale(originSize);
pW->runAction(CCSequence::create(CCDelayTime::create(0.2),Animation::titleCharaAction(originSize),NULL));
this->addChild(pW);
CCSprite* pS = CCSprite::create("logo_S.png");
pS->setPosition(ccp(size.width * 0.9, size.height * 0.8));
//pS->setScale(0.6);
pS->setScale(originSize);
pS->runAction(CCSequence::create(CCDelayTime::create(0.25),Animation::titleCharaAction(originSize),NULL));
this->addChild(pS);
//start button
CCMenuItemImage* pStartItem;
pStartItem = CCMenuItemImage::create("button1.png", "button1.png",this,menu_selector(TitleScene::menuStartCallback));
pStartItem->setPosition(ccp(size.width * 0.5, size.height * 0.3));
pStartItem->setScale((size.width * 0.4) / pStartItem->getContentSize().width);
CCLabelTTF* startLabel;
startLabel = CCLabelTTF::create("PLAY", "Arial", 30.0);
CCSize pStartItemSize = pStartItem->getContentSize();
startLabel->setPosition(ccp(pStartItemSize.width / 2 ,pStartItemSize.height / 2));
pStartItem->addChild(startLabel);
CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
if(! this->firstTimeGame){
//チュートリアルを再度受けられるようにボタン生成
//start button
CCMenuItemImage* pTutorItem;
pTutorItem = CCMenuItemImage::create("button2.png", "button2.png",this,menu_selector(TitleScene::menuTutorCallback));
pTutorItem->setPosition(ccp(size.width * 0.5, size.height * 0.4));
pTutorItem->setScale((size.width * 0.4) / pTutorItem->getContentSize().width);
CCLabelTTF* tutorLabel;
//.........这里部分代码省略.........
示例11: loginstart
void SGWelComeLayer::loginstart()
{
isstart= false;
testSomething(); //MM: 保留
//发送进入欢迎界面的消息 add by:zyc.
SGMainManager::sendOperatorRecord(100010);
// ((SGButton *)this->getChildByTag(1))->stopAllActions();
// this->removeChildByTag(1, true);
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer = CCLayerColor::create(ccc4(0, 0, 0, 50));
this->addChild(layer, -1);
std::string sbPng = "";
if ( GAME_ACCOUNT_TYPE == GCAT_XDYOU ) //MM: xdyou支持快速登入功能。
{
if (GameConfig::isExist())
{
sbPng = "login_ksksbtn.png";
}
else
{
sbPng = "login_ksksOncebtn.png";
}
}
else if ( GAME_ACCOUNT_TYPE == GCAT_GO2PLAY ) //MM: go2play的快速登陆比较坑爹,需要单独标志位标记。//cgp come here
{
CCUserDefault* ccud = CCUserDefault::sharedUserDefault();
bool isFast = ccud->getBoolForKey("isFastLogin");
if (GameConfig::isExist())
{
if (isFast)
{
sbPng = "login_ksksOncebtn.png";
}
else
{
sbPng = "login_ksksbtn.png";
}
}
else
{
sbPng = "login_ksksOncebtn.png";
}
}
else //MM: 非xdyou和go2play的账号体系,不管是否有过登陆历史,一概无视,重新登陆,即图片为“进入游戏”,而不是“快速开始”。
{
sbPng = "login_ksksbtn.png";
}
startBtn = SGButton::create(sbPng.c_str(), NULL, this, menu_selector(SGWelComeLayer::fastStartHandler),CCPointZero,false,true);
this->addBtn(startBtn);
startBtn->setScale(0.8);
canStart = true;
//不同渠道显示不同文本。
CCString *no = NULL;
if ( (GAME_ACCOUNT_TYPE == GCAT_XDYOU) || (GAME_ACCOUNT_TYPE == GCAT_GO2PLAY) )
{
no = CCString::create(str_WdelcomeLayer_str1);
}
else
{
no = CCString::create(str_WdelcomeLayer_str2);
}
SGCCLabelTTF *notice = SGCCLabelTTF::create(no->getCString(), FONT_BOXINFO,FONTSIZE(13));
this->addChild(notice,100);
CCSprite *noticeBg = CCSprite::createWithSpriteFrameName("loginMsgbg.png");
this->addChild(noticeBg,90);
noticeBg->setScale(0.8);
changeServerbtn = SGButton::createFromLocal("loginbtnText.png", "", this, menu_selector(SGWelComeLayer::changeIDHandler), CCPointZero, FONT_BOXINFO, ccWHITE, 26, false, true);
changeServerbtn->setFontColor(ccWHITE);
changeServerbtn->setScale(0.8);
this->addBtn(changeServerbtn);
//帐号注册
if (GAME_ACCOUNT_TYPE == GCAT_XDYOU)
{
registerBtn = SGButton::createFromLocal("loginbtnText.png",
" ",
this,
menu_selector(SGWelComeLayer::registerHandler), CCPointZero, FONT_BOXINFO, ccWHITE, 26, false, true);
}
//如果渠道SDK不是朋游,帐号部分不可见
else if (GAME_ACCOUNT_TYPE == GCAT_TONGBUTUI)
{
//registerBtn->setVisible(false);
registerBtn = SGButton::createFromLocal("loginbtnText.png", str_WdelcomeLayer_str3, this, menu_selector(SGWelComeLayer::exchangeHandler), CCPointZero, FONT_BOXINFO, ccWHITE, 26, false, true);
}
else if (GAME_ACCOUNT_TYPE == GCAT_PP)//下边部分使用registerBtn太多,暂时初始化,设为不可见
{
registerBtn = SGButton::createFromLocal("loginbtnText.png", str_WdelcomeLayer_str3, this, menu_selector(SGWelComeLayer::exchangeHandler), CCPointZero, FONT_BOXINFO, ccWHITE, 26, false, true);
//.........这里部分代码省略.........
示例12: initWithPage
bool LevelSelectScene::initWithPage(int pageNum)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
// 初期化色を変更
if (!CCLayerColor::initWithColor(ccc4(0xF8,0xEC,0xDE,0xFF))) //RGBA
{
return false;
}
this->page_num = pageNum;
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
// is_tutorial
string tutorialKey = ConstCommon::getTutorialKey();
bool tutorClear = userDefault->getBoolForKey(tutorialKey.c_str());
if( ! tutorClear){
userDefault->setBoolForKey(tutorialKey.c_str(), true);
userDefault->flush();
}
//start button
CCArray* pLevelArr = new CCArray;
//page1->1〜15 ... page2->16〜30
for (int i=1 + ((page_num - 1)* 15); i <= 15 + ((page_num - 1)* 15); i++) {
//create Level Button
pLevelArr->addObject(createLevelImage(i));
}
CCMenu* pMenu = CCMenu::createWithArray(pLevelArr);
pMenu->setPosition(CCPointZero);
pMenu->setTag(tagLevelSelectMenuDialog);
if(this->page_num != 2){
CCMenuItemImage* nextItem = CCMenuItemImage::create("next.png","next.png.png" ,this, menu_selector(LevelSelectScene::showNextPage));
nextItem->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.2));
nextItem->setScale(0.2);
pMenu->addChild(nextItem);
}
if(this->page_num != 1){
CCMenuItemImage* prevItem = CCMenuItemImage::create("prev.png","prev.png" ,this, menu_selector(LevelSelectScene::showPrevPage));
prevItem->setPosition(ccp(winSize.width * 0.2, winSize.height * 0.2));
prevItem->setScale(0.2);
pMenu->addChild(prevItem);
}
this->addChild(pMenu);
CCString* stageSelectStr = CCString::createWithFormat("STAGE SELECT");
CCLabelTTF* stageSelectLabel = CCLabelTTF::create(stageSelectStr->getCString(), "Copperplate", 70.0);
stageSelectLabel->setColor(ccc3(0, 0, 0));
stageSelectLabel->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.95));
this->addChild(stageSelectLabel);
return true;
}