Beispiel #1
0
void MainGameScene::endJudgemnet()
{
    
    setTouchEnabled(true);
    for(int i = 1; i <= COL_NUM * ROW_NUM; i++){
        Arrow* arrowObj = (Arrow *)this->getChildByTag(i);
        if( ! arrowObj->getOnFlag()){
            //まだ全てONになっていない
            return;
        }
    }
    //終了
    endFlag = true;
    
    //ハイスコアであれば保持
    CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
    
    int highScore = userDefault->getFloatForKey(highScoreKey.c_str(),ConstCommon::DEFAULT_HIGH_SCORE_NUM);
    if( highScore > totalGameCount){
        isHighScore = true;
        userDefault->setFloatForKey(highScoreKey.c_str(), totalGameCount);
    }
    
    //ゲーム回数を記録
    int totalAllGameCount = userDefault->getFloatForKey(totalAllGameCountKey.c_str(),0);
    userDefault->setFloatForKey(totalAllGameCountKey.c_str(), totalAllGameCount+1);
    userDefault->flush();
    
    
    
    //終了アニメーション
    this->endAnimation();
    
}
Beispiel #2
0
void GameScene::showHighScoreLabel() {
    CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
    
    const char* highScorekey = "hightscore";
    
    float highScore = userDefault->getFloatForKey(highScorekey, 99.9);
    if (gametime != 0)
    {
        if (gametime > highScore)
        {
            return;
        }
        else
        {
            highScore = gametime;
            
            userDefault->setFloatForKey(highScorekey, highScore);
            userDefault->flush();
        }
    }
    
    const int tagHighScoreLabel = 200;
    
    CCString* highScoreString = CCString::createWithFormat("%8.1fs", highScore);
    
    CCLabelTTF* highScoreLabel = (CCLabelTTF*)this->getChildByTag(tagHighScoreLabel);
    
    if (highScoreLabel)
    {
        highScoreLabel->setString(highScoreString->getCString());
    }
    else
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        highScoreLabel = CCLabelTTF::create(highScoreString->getCString(), "Arial", 24.0);
        highScoreLabel->setPosition(ccp(winSize.width*0.9, winSize.height*0.7));
        highScoreLabel->setTag(tagHighScoreLabel);
        this->addChild(highScoreLabel);
    }
    
}