コード例 #1
0
ファイル: Config.cpp プロジェクト: Asheng321/PopStar
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
0
ファイル: LocalData.cpp プロジェクト: BoenYang/GameProject
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
0
ファイル: GameScene.cpp プロジェクト: yoroyorokun/SpaceShoot
void GameScene::saveScore()
{
	CCUserDefault* ud = CCUserDefault::sharedUserDefault();
	int rank;
	for( rank=1; rank<= 5 ; ++rank){
		char key[4];
		sprintf( key, "Score%dth", rank);
		int score = ud->getIntegerForKey(key,0);
		if( score < m_score )
			break;
	}
	for( int i = 5; i > rank ; --i){
		char key_src[4];
		sprintf( key_src, "Score%dth", i-1);
		char key_dst[4];
		sprintf( key_dst, "Score%dth", i);
		ud->setIntegerForKey(key_dst, ud->getIntegerForKey(key_src,0));
	}
	char key[4];
	sprintf( key, "Score%dth", rank);
	ud->setIntegerForKey(key, m_score);

	CCSprite* crown = NULL;
	switch(rank){
	case 1:
		crown = CCSprite::create("crown_gold.png");
		break;
	case 2:
		crown  = CCSprite::create("crown_silver.png");
		break;
	case 3:
		crown = CCSprite::create("crown_bronze.png");
		break;
	}
	if( crown ){
		crown->setPosition(ccp(m_winSize.width/2,m_winSize.height * 0.7));
		crown->setOpacity(0);
		crown->setScale(0);
		this->addChild(crown,kZOrderScore,kTagCrown);
		CCDelayTime* delay = CCDelayTime::create(0.8f);
		CCFadeIn* fadein = CCFadeIn::create(0.5f);
		CCScaleTo* zoomin = CCScaleTo::create(0.5f,1.0f);
		CCCallFuncN* callfunc = CCCallFuncN::create(this,callfuncN_selector(GameScene::callSkewAnim));
		crown->runAction(CCSequence::create(delay, CCSpawn::createWithTwoActions(fadein, zoomin),callfunc,NULL));
	}
}
コード例 #4
0
ファイル: GameData.cpp プロジェクト: Michael-Z/MyBird
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;
}
コード例 #5
0
ファイル: GameData.cpp プロジェクト: Michael-Z/MyFlappyBird-1
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;
}
コード例 #6
0
ファイル: Common.cpp プロジェクト: Geminichel/ph-open
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);
}
コード例 #7
0
ファイル: AppDelegate.cpp プロジェクト: JoregeSanz/MyRepo
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    float fx = winSize.width / DESIGN_RESOLUTION_WIDTH;
    float fy = winSize.height / DESIGN_RESOLUTION_HEIGHT;
    if (fx > fy)
        g_fResScale = fx;
    else
        g_fResScale = fy;
    
    // create a scene. it's an autorelease object
    // run
    
    CCUserDefault* userdata = CCUserDefault::sharedUserDefault();
    if (!userdata->getIntegerForKey(LEVEL))
    {
        userdata->setIntegerForKey(LEVEL, 1);
    }
    
    CCScene *pScene = LogoScene::scene();
    pDirector->runWithScene(pScene);
//    pDirector->runWithScene(CarGame::scene());
//    pDirector->runWithScene(NinjaScene::scene());

    return true;
}
コード例 #8
0
ファイル: Common.cpp プロジェクト: Geminichel/ph-open
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;
}
コード例 #9
0
ファイル: Level.cpp プロジェクト: curiousily/glow-flow
Level Level::currentLevel() {
	CCUserDefault* db = CCUserDefault::sharedUserDefault();
	int number = db->getIntegerForKey(CURRENT_LEVEL_KEY, DEFAULT_LEVEL);
	return Level::levelFor(number);
}
コード例 #10
0
// Initialize our Main Menu Layer, and add the initial main menu with the title screen, play button and about button.
bool GameOverLayer::init()
{
    // Initialize the parent
    if (!CCLayer::init()) return false;
    
    // Load the high scores
    CCUserDefault *store = CCUserDefault::sharedUserDefault();
    int bestScore = store->getIntegerForKey("best-score", 0);
    int bestDistance = store->getIntegerForKey("best-distance", 0);
    int bestDifficulty = store->getIntegerForKey("best-difficulty", 0);
    bool newRecord = false;
    
    if (GameManager::sharedGameManager()->getScore() > bestScore && GameManager::sharedGameManager()->getDistance() > bestDistance)
    {
        bestScore = GameManager::sharedGameManager()->getScore();
        bestDistance = GameManager::sharedGameManager()->getDistance();
        bestDifficulty = GameManager::sharedGameManager()->getDifficulty();
        store->setIntegerForKey("best-score", bestScore);
        store->setIntegerForKey("best-distance", bestDistance);
        store->setIntegerForKey("best-difficulty", bestDifficulty);
        store->flush();
        newRecord = true;
    }
    
    // Set the screen size to the full dimensions of the device (full screen)
    this->setContentSize(SCREEN_SIZE);
    
    float labelScaleText = 1.2f;
    if (GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid854x480 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid800x480 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid800x400 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid720x480)
    {
        labelScaleText = 0.9f;
    }
    else if (GameManager::sharedGameManager()->getDeviceSize() == kDeviceSizeNormal)
    {
        labelScaleText = 1.0f;
    }
    else if (GameManager::sharedGameManager()->getDeviceSize() == kDeviceSizeSmall)
    {
        labelScaleText = 0.5f;
    }
    
    CCSprite *gameOverTitle = CCSprite::createWithSpriteFrameName("game_over.png");
    gameOverTitle->setScale(0.9f);
    gameOverTitle->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.8));
    this->addChild(gameOverTitle);
    
    CCString *score = CCString::createWithFormat("YOUR SCORE: %i", GameManager::sharedGameManager()->getScore());
    CCLabelBMFont *scoreLabel = CCLabelBMFont::create(score->getCString(), "myGlyphs.fnt");
    scoreLabel->setScale(labelScaleText);
    scoreLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.65));
    this->addChild(scoreLabel);
    
    CCString *distance = CCString::createWithFormat("YOUR DISTANCE: %i", GameManager::sharedGameManager()->getDistance());
    CCLabelBMFont *distanceLabel = CCLabelBMFont::create(distance->getCString(), "myGlyphs.fnt");
    distanceLabel->setScale(labelScaleText);
    distanceLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.59));
    this->addChild(distanceLabel);
    
    CCString *ydifficulty;
    switch (GameManager::sharedGameManager()->getDifficulty())
    {
        case 3:
            ydifficulty = CCString::create("HARD");
            break;
        case 2:
            ydifficulty = CCString::create("MEDIUM");
            break;
        default:
            ydifficulty = CCString::create("EASY");
    }
    
    CCString *difficulty = CCString::createWithFormat("YOUR DIFFICULTY: %s", ydifficulty->getCString());
    CCLabelBMFont *difficultyLabel = CCLabelBMFont::create(difficulty->getCString(), "myGlyphs.fnt");
    difficultyLabel->setScale(labelScaleText);
    difficultyLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.53));
    this->addChild(difficultyLabel);
    
    CCString *highScore = CCString::createWithFormat("HIGH SCORE: %i", bestScore);
    CCLabelBMFont *highScoreLabel = CCLabelBMFont::create(highScore->getCString(), "myGlyphs.fnt");
    highScoreLabel->setScale(labelScaleText);
    highScoreLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.43));
    this->addChild(highScoreLabel);
    
    CCString *highDistance = CCString::createWithFormat("BEST DISTANCE: %i", bestDistance);
    CCLabelBMFont *highDistanceLabel = CCLabelBMFont::create(highDistance->getCString(), "myGlyphs.fnt");
    highDistanceLabel->setScale(labelScaleText);
    highDistanceLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.37));
    this->addChild(highDistanceLabel);
    
    CCString *bdifficulty;
    switch (bestDifficulty)
    {
        case 3:
            bdifficulty = CCString::create("HARD");
            break;
        case 2:
            bdifficulty = CCString::create("MEDIUM");
            break;
        default:
            bdifficulty = CCString::create("EASY");
    }
    
    CCString *highDifficulty = CCString::createWithFormat("DIFFICULTY: %s", bdifficulty->getCString());
    CCLabelBMFont *highDifficultyLabel = CCLabelBMFont::create(highDifficulty->getCString(), "myGlyphs.fnt");
    highDifficultyLabel->setScale(labelScaleText);
    highDifficultyLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.31));
    this->addChild(highDifficultyLabel);
    
    // Play again button
    createPlayAgainButton();
    
    // Play Game Over Sound
    CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_gameover.mp3", false);
    
    // Do new record animation
    if (newRecord)
    {
        // TODO
    }
    
    // Initialization was successful
    return true;
}