コード例 #1
0
ファイル: MainGameScene.cpp プロジェクト: k-tetsuhiro/app02
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();
    
}
コード例 #2
0
ファイル: LevelScene.cpp プロジェクト: ikermendi/Ikasitz
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;
}
コード例 #3
0
ファイル: MenuScene.cpp プロジェクト: ikermendi/Ikasitz
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;
}
コード例 #4
0
ファイル: GameScene.cpp プロジェクト: Yarimizu14/nyan25
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);
    }
    
}
コード例 #5
0
CCMenuItemImage* LevelSelectScene::createLevelImage(int level)
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCString* levelString = CCString::createWithFormat("%d",level);
    
    
    //bestScoreも初期化
    CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
    highScoreKey = ConstCommon::getHighScoreKey(level);
    best_score[level-1] = userDefault->getFloatForKey(highScoreKey.c_str(),99);
    
    //minScoreも初期化
    CCString* jsonFileName = CCString::createWithFormat("Lv%d.json",level);
    GameData* gm = new GameData(jsonFileName->getCString());
    min_score[level-1] = gm->getMinScore();
    
    int rank;
    
    if(min_score[level-1] >= best_score[level-1]){
        rank = 3;
    }else if( min_score[level-1] <= best_score[level-1] + 8){
        rank = 2;
    }else{
        rank = 1;
    }
    
    
    int fileNum = ((level - 1) / 3) + 1;
    if(fileNum > 5){
        fileNum = fileNum - (( fileNum / 5) * 5) + 1;
    }
    CCString* filePathName = CCString::createWithFormat("level_circle_%d.png",fileNum);

    CCMenuItemImage* pLevel;
    pLevel = CCMenuItemImage::create(filePathName->getCString(), filePathName->getCString(),this,menu_selector(LevelSelectScene::menuStartCallback));
    pLevel->setScale(0.25);
    pLevel->setScale( ((size.width * 0.585) / 3) / pLevel->getContentSize().width );
    
    int posLevel = level - (15 * ((level - 1) / 15));
    pLevel->setPosition(ccp(
                            size.width * (((((posLevel - 1) % 3) + 1) * 0.3) - 0.1),
                            size.height * (0.9 - (((posLevel - 1) / 3 ) * 0.128)) - 70
                            ));
    
    CCSize pLevelSize = pLevel->getContentSize();
    
    if(best_score[level-1] != 99){
        for (int i=0; i < rank; i++) {
            CCSprite* pStar = CCSprite::create("level_star.png");
            
            if(i == 0){
                pStar->setPosition(ccp(pLevelSize.width * 0.5 - pStar->getContentSize().width, pLevelSize.height * 0.75));
            }else if(i == 1){
                pStar->setPosition(ccp(pLevelSize.width * 0.5, pLevelSize.height * 0.75));
            }else{
                pStar->setPosition(ccp(pLevelSize.width * 0.5 + pStar->getContentSize().width, pLevelSize.height * 0.75));
            }
           
            pLevel->addChild(pStar);
        }

    }

    
    
    CCLabelTTF* levelLabel;
    levelLabel = CCLabelTTF::create(levelString->getCString(), "Arial", 150.0);
    levelLabel->setColor(ccc3(0x00,0x00,0x00));
    
    levelLabel->setPosition(ccp(pLevelSize.width / 2 ,pLevelSize.height / 2));
    pLevel->addChild(levelLabel);
    
    pLevel->setTag(level);

    return pLevel;
}