标签:
void LevelSelectContent::initAllLevels(int page){ this->removeAllChildren(); const int eachPageItemCount = g_EachPageCount; _levelMenu = Menu::create(); this->addChild(_levelMenu); int const constStartPositionX = VISIBLE_WIDTH * 0.5 - levelMarginX * (g_EachLineCount / 2 - 0.5); int startPositionX = constStartPositionX; int topStartPositionY = VISIBLE_HEIGHT * 0.5 + levelMarginY * (g_EachPageCount / g_EachLineCount / 2 - 0.5); for(int i = 0 + page * eachPageItemCount; i < eachPageItemCount + page * eachPageItemCount; i++){ if(i < g_maxLevel){ int lineCount = g_EachLineCount; if(i!= (0 + page * eachPageItemCount) && i % lineCount == 0){ startPositionX = constStartPositionX; topStartPositionY = topStartPositionY - levelMarginY; } int levelCount = i + 1; auto oneLevelItem = LevelSelectItem::create(levelCount); _levelMenu->addChild(oneLevelItem); oneLevelItem->setPosition(startPositionX, topStartPositionY); startPositionX += levelMarginX; } } _levelMenu->setPosition(0, 0); _levelMenu->setOpacity(0); auto fadeAction = FadeIn::create(0.5); _levelMenu->runAction(fadeAction); }
typedef enum{ kAlreadyPass, kNotPassYet, kLockLevel }LevelItemType;
LevelSelectItem::LevelSelectItem(int level):_level(level),_type(kLockLevel){ if(level > (g_passLevelCount + 1)){ this->setEnabled(false); _type = kLockLevel; }else if(level == (g_passLevelCount + 1)){ this->setEnabled(true); _type = kNotPassYet; }else if(level < (g_passLevelCount + 1)){ this->setEnabled(true); _type = kAlreadyPass; } }
标签:
原文地址:http://blog.csdn.net/fox64194167/article/details/42400011