PuzzleSDK
LabelTTFDistanceField类 参考

#include <LabelTestNew.h>

+ 类 LabelTTFDistanceField 继承关系图:
+ LabelTTFDistanceField 的协作图:

Public 成员函数

 CREATE_FUNC (LabelTTFDistanceField)
 
 LabelTTFDistanceField ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 LabelTestNew.h326 行定义.

构造及析构函数说明

◆ LabelTTFDistanceField()

LabelTTFDistanceField::LabelTTFDistanceField ( )

在文件 LabelTestNew.cpp1209 行定义.

1210{
1211 auto size = Director::getInstance()->getWinSize();
1212 TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true);
1213
1214 auto label1 = Label::createWithTTF(ttfConfig,"Distance Field",TextHAlignment::CENTER,size.width);
1215 label1->setPosition( Vec2(size.width/2, size.height * 0.6f) );
1216 label1->setTextColor( Color4B::GREEN );
1217 addChild(label1);
1218
1219 auto action = Sequence::create(
1220 DelayTime::create(1.0f),
1221 ScaleTo::create(6.0f,5.0f,5.0f),
1222 ScaleTo::create(6.0f,1.0f,1.0f),
1223 nullptr);
1224 label1->runAction(RepeatForever::create(action));
1225
1226 // Draw the label border
1227 auto& labelContentSize = label1->getContentSize();
1228 auto borderDraw = DrawNode::create();
1229 label1->addChild(borderDraw);
1230 borderDraw->clear();
1231 borderDraw->setLineWidth(1);
1232 Vec2 vertices[4] =
1233 {
1234 Vec2::ZERO,
1235 Vec2(labelContentSize.width, 0.0f),
1236 Vec2(labelContentSize.width, labelContentSize.height),
1237 Vec2(0.0f, labelContentSize.height)
1238 };
1239 borderDraw->drawPoly(vertices, 4, true, Color4F::RED);
1240
1241 auto label2 = Label::createWithTTF(ttfConfig,"Distance Field",TextHAlignment::CENTER,size.width);
1242 label2->setPosition( Vec2(size.width/2, size.height * 0.3f) );
1243 label2->setTextColor( Color4B::RED );
1244 addChild(label2);
1245
1246 // Draw the label border
1247 auto& labelContentSize2 = label2->getContentSize();
1248 auto borderDraw2 = DrawNode::create();
1249 label2->addChild(borderDraw2);
1250 borderDraw2->clear();
1251 borderDraw2->setLineWidth(1);
1252 Vec2 vertices2[4] =
1253 {
1254 Vec2::ZERO,
1255 Vec2(labelContentSize2.width, 0.0f),
1256 Vec2(labelContentSize2.width, labelContentSize2.height),
1257 Vec2(0.0f, labelContentSize2.height)
1258 };
1259 borderDraw2->drawPoly(vertices2, 4, true, Color4F::GREEN);
1260}

成员函数说明

◆ CREATE_FUNC()

LabelTTFDistanceField::CREATE_FUNC ( LabelTTFDistanceField  )

◆ subtitle()

std::string LabelTTFDistanceField::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 LabelTestNew.cpp1267 行定义.

1268{
1269 return "Testing rendering base on DistanceField";
1270}

◆ title()

std::string LabelTTFDistanceField::title ( ) const
overridevirtual

重载 TestCase .

在文件 LabelTestNew.cpp1262 行定义.

1263{
1264 return "New Label + .TTF";
1265}

该类的文档由以下文件生成: