| 1885 | } |
| 1886 | |
| 1887 | LabelTTFOldNew::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 | |
| 1928 | std::string LabelTTFOldNew::title() const |
| 1929 | { |
nothing calls this directly
no test coverage detected