| 39 | bool LevelPage::replacingScene = false; |
| 40 | |
| 41 | bool LevelPage::init(GJGameLevel* level) |
| 42 | { |
| 43 | if (!Layer::init()) return false; |
| 44 | |
| 45 | LevelPage::replacingScene = false; |
| 46 | |
| 47 | //testing |
| 48 | //level->_normalPercent = static_cast<float>(GameToolbox::randomInt(0, 100)); |
| 49 | //level->_practicePercent = static_cast<float>(GameToolbox::randomInt(0, 100)); |
| 50 | |
| 51 | GameToolbox::log("normal: {}, practice: {}", level->_normalPercent, level->_practicePercent); |
| 52 | |
| 53 | _level = level; |
| 54 | std::string barTexture = GameToolbox::getTextureString("GJ_progressBar_001.png"); |
| 55 | std::string bigFontTexture = GameToolbox::getTextureString("bigFont.fnt"); |
| 56 | |
| 57 | const auto& winSize = ax::Director::getInstance()->getWinSize(); |
| 58 | |
| 59 | //TODO: fix bars lol |
| 60 | auto normalBar = ax::Sprite::create(barTexture); |
| 61 | normalBar->setPosition({ winSize.width / 2, winSize.height / 2.f - 30 }); |
| 62 | normalBar->setColor({0, 0, 0}); |
| 63 | normalBar->setOpacity(125); |
| 64 | addChild(normalBar, 3); |
| 65 | |
| 66 | auto normalProgress = ax::Sprite::create(barTexture); |
| 67 | normalProgress->setPosition({1.36f, 10}); |
| 68 | normalProgress->setColor({0, 255, 0}); |
| 69 | normalProgress->setOpacity(255); |
| 70 | normalProgress->setAnchorPoint({0, 0.5}); |
| 71 | normalProgress->setContentSize({340 / (level->_normalPercent / 100.f), 20}); |
| 72 | normalProgress->setScale(0.992f); |
| 73 | normalProgress->setScaleX(0.992f); |
| 74 | normalProgress->setScaleY(0.86f); |
| 75 | normalBar->addChild(normalProgress); |
| 76 | |
| 77 | |
| 78 | auto practiceBar = ax::Sprite::create(barTexture); |
| 79 | practiceBar->setPosition({ winSize.width / 2, winSize.height / 2.f - 80 }); |
| 80 | practiceBar->setColor({0, 0, 0}); |
| 81 | practiceBar->setOpacity(125); |
| 82 | addChild(practiceBar, 3); |
| 83 | |
| 84 | auto practiceProgress = ax::Sprite::create(barTexture); |
| 85 | practiceProgress->setPosition({1.36f, 10}); |
| 86 | practiceProgress->setColor({0, 255, 0}); |
| 87 | practiceProgress->setOpacity(255); |
| 88 | practiceProgress->setAnchorPoint({0, 0.5}); |
| 89 | practiceProgress->setContentSize({340 / (level->_normalPercent / 100.f), 20}); |
| 90 | practiceProgress->setScale(0.992f); |
| 91 | practiceProgress->setScaleX(0.992f); |
| 92 | practiceProgress->setScaleY(0.86f); |
| 93 | practiceBar->addChild(practiceProgress); |
| 94 | |
| 95 | auto normalText = ax::Label::createWithBMFont(bigFontTexture, "Normal Mode"); |
| 96 | normalText->setPosition({ winSize.width / 2, winSize.height / 2.f - 10 }); |
| 97 | // normalText->enableShadow(ax::Color4B::BLACK, {0.2, -0.2}); |
| 98 | normalText->setScale(0.55f); |
no test coverage detected