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

Method LabelTTFOldNew

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:1887–1926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1885}
1886
1887LabelTTFOldNew::LabelTTFOldNew()
1888{
1889 auto s = Director::getInstance()->getWinSize();
1890 float delta = s.height / 4;
1891
1892 auto label1 = Label::createWithSystemFont("Axmol Label Test", "arial", 24);
1893 addChild(label1, 0, kTagBitmapAtlas1);
1894 label1->setPosition(Vec2(s.width / 2, delta * 2));
1895 label1->setColor(Color3B::RED);
1896
1897 TTFConfig ttfConfig("fonts/arial.ttf", 24);
1898 auto label2 = Label::createWithTTF(ttfConfig, "Axmol Label Test");
1899 addChild(label2, 0, kTagBitmapAtlas2);
1900 label2->setPosition(Vec2(s.width / 2, delta * 2));
1901
1902 auto drawNode = DrawNode::create();
1903 auto labelSize = label1->getContentSize();
1904 auto origin = Director::getInstance()->getWinSize();
1905
1906 origin.width = origin.width / 2 - (labelSize.width / 2);
1907 origin.height = origin.height / 2 - (labelSize.height / 2);
1908
1909 Vec2 vertices[4] = {Vec2(origin.width, origin.height), Vec2(labelSize.width + origin.width, origin.height),
1910 Vec2(labelSize.width + origin.width, labelSize.height + origin.height),
1911 Vec2(origin.width, labelSize.height + origin.height)};
1912 drawNode->drawPoly(vertices, 4, true, Color4F(1.0f, 0.0f, 0.0f, 1.0f));
1913
1914 labelSize = label2->getContentSize();
1915 origin = Director::getInstance()->getWinSize();
1916
1917 origin.width = origin.width / 2 - (labelSize.width / 2);
1918 origin.height = origin.height / 2 - (labelSize.height / 2);
1919
1920 Vec2 vertices2[4] = {Vec2(origin.width, origin.height), Vec2(labelSize.width + origin.width, origin.height),
1921 Vec2(labelSize.width + origin.width, labelSize.height + origin.height),
1922 Vec2(origin.width, labelSize.height + origin.height)};
1923 drawNode->drawPoly(vertices2, 4, true, Color4F(1.0f, 1.0f, 1.0f, 1.0f));
1924
1925 addChild(drawNode);
1926}
1927
1928std::string LabelTTFOldNew::title() const
1929{

Callers

nothing calls this directly

Calls 8

getInstanceFunction · 0.85
createFunction · 0.85
drawPolyMethod · 0.80
Vec2Function · 0.50
Color4FFunction · 0.50
setPositionMethod · 0.45
setColorMethod · 0.45
getContentSizeMethod · 0.45

Tested by

no test coverage detected