| 1286 | } |
| 1287 | |
| 1288 | LabelTTFDistanceField::LabelTTFDistanceField() |
| 1289 | { |
| 1290 | auto size = Director::getInstance()->getWinSize(); |
| 1291 | TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC, nullptr, true); |
| 1292 | |
| 1293 | auto label1 = Label::createWithTTF(ttfConfig, "Distance Field", TextHAlignment::CENTER, size.width); |
| 1294 | label1->setPosition(Vec2(size.width / 2, size.height * 0.6f)); |
| 1295 | label1->setTextColor(Color4B::GREEN); |
| 1296 | addChild(label1); |
| 1297 | |
| 1298 | auto action = Sequence::create(DelayTime::create(1.0f), ScaleTo::create(6.0f, 5.0f, 5.0f), |
| 1299 | ScaleTo::create(6.0f, 1.0f, 1.0f), nullptr); |
| 1300 | label1->runAction(RepeatForever::create(action)); |
| 1301 | |
| 1302 | // Draw the label border |
| 1303 | auto& labelContentSize = label1->getContentSize(); |
| 1304 | auto borderDraw = DrawNode::create(); |
| 1305 | label1->addChild(borderDraw); |
| 1306 | borderDraw->clear(); |
| 1307 | Vec2 vertices[4] = {Vec2::ZERO, Vec2(labelContentSize.width, 0.0f), |
| 1308 | Vec2(labelContentSize.width, labelContentSize.height), Vec2(0.0f, labelContentSize.height)}; |
| 1309 | borderDraw->drawPoly(vertices, 4, true, Color4F::RED); |
| 1310 | |
| 1311 | auto label2 = Label::createWithTTF(ttfConfig, "Distance Field", TextHAlignment::CENTER, size.width); |
| 1312 | label2->setPosition(Vec2(size.width / 2, size.height * 0.3f)); |
| 1313 | label2->setTextColor(Color4B::RED); |
| 1314 | addChild(label2); |
| 1315 | |
| 1316 | // Draw the label border |
| 1317 | auto& labelContentSize2 = label2->getContentSize(); |
| 1318 | auto borderDraw2 = DrawNode::create(); |
| 1319 | label2->addChild(borderDraw2); |
| 1320 | borderDraw2->clear(); |
| 1321 | Vec2 vertices2[4] = {Vec2::ZERO, Vec2(labelContentSize2.width, 0.0f), |
| 1322 | Vec2(labelContentSize2.width, labelContentSize2.height), Vec2(0.0f, labelContentSize2.height)}; |
| 1323 | borderDraw2->drawPoly(vertices2, 4, true, Color4F::GREEN); |
| 1324 | } |
| 1325 | |
| 1326 | std::string LabelTTFDistanceField::title() const |
| 1327 | { |
nothing calls this directly
no test coverage detected