MCPcopy Create free account
hub / github.com/axmolengine/axmol / onEnter

Method onEnter

tests/cpp-tests/Source/FontTest/FontTest.cpp:179–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void FontNoReplacementTest::onEnter()
180{
181 TestCase::onEnter();
182
183 std::string suffix;
184 auto s = Director::getInstance()->getWinSize();
185
186 auto blockSize = Size(s.width / 3, 200);
187 float fontSize = 26;
188
189 removeChildByTag(kTagLabel1, true);
190 removeChildByTag(kTagLabel2, true);
191 removeChildByTag(kTagLabel3, true);
192 removeChildByTag(kTagLabel4, true);
193 removeChildByTag(kTagColor1, true);
194 removeChildByTag(kTagColor2, true);
195 removeChildByTag(kTagColor3, true);
196
197 auto top = Label::createWithTTF("fonts/A Damn Mess.ttf" + suffix, "fonts/A Damn Mess.ttf", 24);
198 auto left = Label::createWithTTF("fonts/Abberancy.ttf" + suffix, "fonts/Abberancy.ttf", fontSize, blockSize,
199 TextHAlignment::LEFT, verticalAlignment[0]);
200 auto center = Label::createWithTTF("fonts/Abduction.ttf" + suffix, "fonts/Abduction.ttf", fontSize, blockSize,
201 TextHAlignment::CENTER, verticalAlignment[0]);
202 auto right = Label::createWithTTF("fonts/Schwarzwald.ttf" + suffix, "fonts/Schwarzwald.ttf", fontSize, blockSize,
203 TextHAlignment::RIGHT, verticalAlignment[0]);
204
205 auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
206 auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
207 auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height);
208
209 leftColor->setIgnoreAnchorPointForPosition(false);
210 centerColor->setIgnoreAnchorPointForPosition(false);
211 rightColor->setIgnoreAnchorPointForPosition(false);
212
213 top->setAnchorPoint(Vec2(0.5, 1));
214 left->setAnchorPoint(Vec2(0, 0.5));
215 leftColor->setAnchorPoint(Vec2(0, 0.5));
216 center->setAnchorPoint(Vec2(0, 0.5));
217 centerColor->setAnchorPoint(Vec2(0, 0.5));
218 right->setAnchorPoint(Vec2(0, 0.5));
219 rightColor->setAnchorPoint(Vec2(0, 0.5));
220
221 top->setPosition(s.width / 2, s.height - 20);
222 left->setPosition(0, s.height / 2);
223 leftColor->setPosition(left->getPosition());
224 center->setPosition(blockSize.width, s.height / 2);
225 centerColor->setPosition(center->getPosition());
226 right->setPosition(blockSize.width * 2, s.height / 2);
227 rightColor->setPosition(right->getPosition());
228
229 this->addChild(leftColor, -1, kTagColor1);
230 this->addChild(left, 0, kTagLabel1);
231 this->addChild(rightColor, -1, kTagColor2);
232 this->addChild(right, 0, kTagLabel2);
233 this->addChild(centerColor, -1, kTagColor3);
234 this->addChild(center, 0, kTagLabel3);
235 this->addChild(top, 0, kTagLabel4);
236}

Callers

nothing calls this directly

Calls 10

getInstanceFunction · 0.85
createFunction · 0.85
Color4BFunction · 0.85
SizeFunction · 0.50
Vec2Function · 0.50
setAnchorPointMethod · 0.45
setPositionMethod · 0.45
getPositionMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected