| 68 | } |
| 69 | |
| 70 | bool LevelInfoLayer::init(GJGameLevel* level) |
| 71 | { |
| 72 | if (!Layer::init()) return false; |
| 73 | const auto& winSize = Director::getInstance()->getWinSize(); |
| 74 | |
| 75 | _level = level; |
| 76 | |
| 77 | GameToolbox::createBG(this); |
| 78 | GameToolbox::createCorners(this, false, false, true, true); |
| 79 | |
| 80 | auto backBtnMenu = Menu::create(); |
| 81 | auto backBtn = MenuItemSpriteExtra::create("GJ_arrow_01_001.png", [](Node*) { GameToolbox::popSceneWithTransition(0.5f); }); |
| 82 | backBtnMenu->addChild(backBtn); |
| 83 | backBtnMenu->setPosition({24.0, winSize.height - 23.0f}); |
| 84 | this->addChild(backBtnMenu); |
| 85 | |
| 86 | auto levelName = GameToolbox::createBMFont(level->_levelName, "bigFont.fnt"); |
| 87 | levelName->setPosition({winSize.width / 2, winSize.height - 17.0f}); |
| 88 | GameToolbox::limitLabelWidth(levelName, 300, 0.8f); |
| 89 | this->addChild(levelName); |
| 90 | |
| 91 | auto levelCreator = GameToolbox::createBMFont(fmt::format("By {}", level->_levelCreator), "goldFont.fnt"); |
| 92 | if (level->_levelCreator == "-") levelCreator->setColor(ax::Color3B(90, 255, 255)); // thanks gd colon |
| 93 | levelCreator->setPosition({winSize.width / 2, levelName->getPositionY() - 30.f}); |
| 94 | GameToolbox::limitLabelWidth(levelCreator, 300, 0.8f); |
| 95 | this->addChild(levelCreator); |
| 96 | |
| 97 | auto rate = Sprite::createWithSpriteFrameName("GJ_featuredCoin_001.png"); |
| 98 | rate->setPosition({ winSize.width / 2 - 100, winSize.height / 2 + 70 }); |
| 99 | rate->setVisible(false); |
| 100 | this->addChild(rate); |
| 101 | |
| 102 | if (level->_featureScore > 0) rate->setVisible(true); |
| 103 | if (level->_epic) { |
| 104 | rate->createWithSpriteFrameName("GJ_epicCoin_001.png"); |
| 105 | rate->initWithSpriteFrameName("GJ_epicCoin_001.png"); |
| 106 | rate->setVisible(true); |
| 107 | } |
| 108 | |
| 109 | auto diff = Sprite::createWithSpriteFrameName(GJGameLevel::getDifficultySprite(level, kLevelInfoLayer)); |
| 110 | diff->setPosition(rate->getPosition()); |
| 111 | this->addChild(diff); |
| 112 | |
| 113 | if(level->_stars > 0) { |
| 114 | auto star = Sprite::createWithSpriteFrameName("star_small01_001.png"); |
| 115 | star->setPosition({ diff->getPositionX() + 8, diff->getPositionY() - 38 }); |
| 116 | this->addChild(star); |
| 117 | |
| 118 | auto starCount = GameToolbox::createBMFont(std::to_string(level->_stars), "bigFont.fnt"); |
| 119 | if (level->_normalPercent >= 100) starCount->setColor({ 255, 255, 0 }); |
| 120 | starCount->setScale(.38); |
| 121 | starCount->setPosition({ diff->getPositionX() - 6, star->getPositionY() }); |
| 122 | this->addChild(starCount); |
| 123 | } |
| 124 | auto downIcon = Sprite::createWithSpriteFrameName("GJ_downloadsIcon_001.png"); |
| 125 | downIcon->setPosition({ winSize.width / 2 + 90.5f, winSize.height / 2 + 90 }); |
| 126 | this->addChild(downIcon); |
| 127 |
no test coverage detected