MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / init

Method init

Source/EndLevelLayer.cpp:114–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114bool EndLevelLayer::init(PlayLayer *pl)
115{
116 auto nd = ax::Layer::create();
117 _statsLayer = DropDownLayer::create(nd, "");
118 _statsLayer->showLayer(_createdWithoutPlaylayer, true);
119 _statsLayer->hideBackButton();
120 _playlayer = pl;
121 if (!_createdWithoutPlaylayer)
122 pl->m_pHudLayer->addChild(_statsLayer);
123 const auto& wsize = ax::Director::getInstance()->getWinSize();
124
125 // level complete image
126
127 auto sprite = ax::Sprite::createWithSpriteFrameName("GJ_levelComplete_001.png");
128 sprite->setScale(0.8f);
129 sprite->setPositionY(wsize.height / 4.5);
130 nd->addChild(sprite);
131
132 //just call once and use
133 std::string goldFontStr = GameToolbox::getTextureString("goldFont.fnt");
134 std::string bigFontStr = GameToolbox::getTextureString("bigFont.fnt");
135
136 // attempts
137 std::string attemptsText = fmt::format("Attempts: {}", _attempts);
138 auto attempts = ax::Label::createWithBMFont(goldFontStr, attemptsText);
139 attempts->setPositionY(wsize.height / 5 - 25 - 10);
140 attempts->setScale(0.8f);
141 nd->addChild(attempts);
142
143 // jumps
144 std::string jumpsText = fmt::format("Jumps: {}", _jumps);
145 auto jumps = ax::Label::createWithBMFont(goldFontStr, jumpsText);
146 jumps->setPositionY(wsize.height / 5 - 50 - 10);
147 jumps->setScale(0.8f);
148 nd->addChild(jumps);
149
150 // time
151 std::chrono::seconds duration{_time};
152 std::string timeText = fmt::format("Time: {:%M:%S}", duration);
153 auto time = ax::Label::createWithBMFont(goldFontStr, timeText);
154 time->setPositionY(wsize.height / 5 - 75 - 10);
155 time->setScale(0.8f);
156 nd->addChild(time);
157
158 // random string
159
160 std::string_view randomText = EndLevelLayer::getRandomEndingString();
161
162 if (_testmode) {
163 randomText = "Level Verified!";
164 }
165
166 auto randomt = ax::Label::createWithBMFont(bigFontStr, randomText);
167 randomt->setPositionY(wsize.height / 5 - 120 - 10);
168 if (randomText.length() > 13)
169 {
170 randomt->setScale(0.75f);
171 }

Callers 1

createMethod · 0.45

Calls 11

createFunction · 0.85
showLayerMethod · 0.80
hideBackButtonMethod · 0.80
setScaleMethod · 0.80
setPositionMethod · 0.80
hideLayerMethod · 0.80
setOpacityMethod · 0.80
setRotationMethod · 0.80
to_stringFunction · 0.50
resetLevelMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected