1539 auto s = Director::getInstance()->getWinSize();
1540 float delta = s.height/4;
1542 auto label1 = Label::createWithSystemFont(
"Cocos2d-x Label Test",
"arial", 24);
1544 label1->setPosition(Vec2(s.width/2, delta * 2));
1545 label1->setColor(Color3B::RED);
1547 TTFConfig ttfConfig(
"fonts/arial.ttf", 24);
1548 auto label2 = Label::createWithTTF(ttfConfig,
"Cocos2d-x Label Test");
1550 label2->setPosition(Vec2(s.width/2, delta * 2));
1552 auto drawNode = DrawNode::create();
1553 auto labelSize = label1->getContentSize();
1554 auto origin = Director::getInstance()->getWinSize();
1556 origin.width = origin.width / 2 - (labelSize.width / 2);
1557 origin.height = origin.height / 2 - (labelSize.height / 2);
1561 Vec2(origin.width, origin.height),
1562 Vec2(labelSize.width + origin.width, origin.height),
1563 Vec2(labelSize.width + origin.width, labelSize.height + origin.height),
1564 Vec2(origin.width, labelSize.height + origin.height)
1566 drawNode->drawPoly(vertices, 4,
true, Color4F(1.0f, 0.0f, 0.0f, 1.0f));
1568 labelSize = label2->getContentSize();
1569 origin = Director::getInstance()->getWinSize();
1571 origin.width = origin.width / 2 - (labelSize.width / 2);
1572 origin.height = origin.height / 2 - (labelSize.height / 2);
1576 Vec2(origin.width, origin.height),
1577 Vec2(labelSize.width + origin.width, origin.height),
1578 Vec2(labelSize.width + origin.width, labelSize.height + origin.height),
1579 Vec2(origin.width, labelSize.height + origin.height)
1581 drawNode->drawPoly(vertices2, 4,
true, Color4F(1.0f, 1.0f, 1.0f, 1.0f));