Exemplo n.º 1
0
void MainGameScene::makeArrows()
{
    
    //GameDataの読み込み
    CCString* jsonFileName = CCString::createWithFormat("Lv%d.json",m_level);
    GameData* gm = new GameData(jsonFileName->getCString());
    
    //矢印の方向
    int *arrowDirection = gm->getDirectionArray();
    
    //矢印の方向
    int *arrowFront = gm->getFrontArray();

    //最小手数
    minimamCount = gm->getMinScore();
    
    
    // higscorekey:m_level
    highScoreKey = ConstCommon::getHighScoreKey(m_level);
    
    //totalGameCount
    totalAllGameCountKey = ConstCommon::getTotalAllGameCountKey();


    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    for(int row = 1; row <= ROW_NUM; row++){
        for(int col = 1; col <= COL_NUM; col++){
            
            int index = ((row - 1) * COL_NUM) + col;
            
            Arrow* arrowObj = Arrow::create();
            
            CCSprite* pArrowOn = CCSprite::create("button_on.png");
            CCSprite* pArrowOff = CCSprite::create("button_off.png");
            
            arrowObj->setDirection(arrowDirection[index - 1]);
            
            arrowObj->setArrowOnSprite(pArrowOn);
            arrowObj->setArrowOffSprite(pArrowOff);
            
            CCSize arrowOffSize = pArrowOff->getContentSize();
            pArrowOff->setPosition(ccp( ((winSize.width - arrowOffSize.width * COL_NUM) / 2) + (arrowOffSize.width / 2 ) + (col - 1) * arrowOffSize.width  ,
                                       ((winSize.height - arrowOffSize.height * ROW_NUM) / 2) + (arrowOffSize.height / 2 ) + (row - 1) * arrowOffSize.height
                                       ));
            
            CCSize arrowOnSize = pArrowOn->getContentSize();
            pArrowOn->setPosition(ccp( ((winSize.width - arrowOnSize.width * COL_NUM) / 2) + (arrowOnSize.width / 2 ) + (col - 1) * arrowOnSize.width  ,
                                      ((winSize.height - arrowOnSize.height * ROW_NUM) / 2) + (arrowOnSize.height / 2 ) + (row - 1) * arrowOnSize.height
                                      ));
            if(arrowFront[index - 1] == 1){
                arrowObj->onFrontArrowSprite(pArrowOff);
            }else{
                arrowObj->onFrontArrowSprite(pArrowOn);
            }
            
           
            arrowObj->setTag(index);
            this->addChild(arrowObj);
        }
        
        
    }
}
Exemplo n.º 2
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;
}