PuzzleSDK
FontTest类 参考

#include <FontTest.h>

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

Public 成员函数

void showFont (const std::string &fontFile)
 
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
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 成员函数

static FontTestcreate (const std::string &fontFile)
 

额外继承的成员函数

- 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
 

详细描述

在文件 FontTest.h33 行定义.

成员函数说明

◆ create()

static FontTest * FontTest::create ( const std::string &  fontFile)
inlinestatic

在文件 FontTest.h36 行定义.

37 {
38 auto ret = new (std::nothrow) FontTest;
39 if (ret && ret->init())
40 {
41 ret->showFont(fontFile);
42 ret->autorelease();
43 }
44 else
45 {
46 delete ret;
47 ret = nullptr;
48 }
49
50 return ret;
51 }
void showFont(const std::string &fontFile)
Definition: FontTest.cpp:83

引用了 showFont().

+ 函数调用图:

◆ showFont()

void FontTest::showFont ( const std::string &  fontFile)

在文件 FontTest.cpp83 行定义.

84{
85 auto s = Director::getInstance()->getWinSize();
86
87 auto blockSize = Size(s.width/3, 200);
88 float fontSize = 26;
89
90 removeChildByTag(kTagLabel1, true);
91 removeChildByTag(kTagLabel2, true);
92 removeChildByTag(kTagLabel3, true);
93 removeChildByTag(kTagLabel4, true);
94 removeChildByTag(kTagColor1, true);
95 removeChildByTag(kTagColor2, true);
96 removeChildByTag(kTagColor3, true);
97
98 auto top = Label::createWithSystemFont(fontFile, fontFile, 24);
99 auto left = Label::createWithSystemFont("alignment left", fontFile, fontSize,
100 blockSize, TextHAlignment::LEFT, verticalAlignment[vAlignIdx]);
101 auto center = Label::createWithSystemFont("alignment center", fontFile, fontSize,
102 blockSize, TextHAlignment::CENTER, verticalAlignment[vAlignIdx]);
103 auto right = Label::createWithSystemFont("alignment right", fontFile, fontSize,
104 blockSize, TextHAlignment::RIGHT, verticalAlignment[vAlignIdx]);
105
106 auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
107 auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
108 auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height);
109
110 leftColor->setIgnoreAnchorPointForPosition(false);
111 centerColor->setIgnoreAnchorPointForPosition(false);
112 rightColor->setIgnoreAnchorPointForPosition(false);
113
114
115 top->setAnchorPoint(Vec2(0.5, 1));
116 left->setAnchorPoint(Vec2(0,0.5));
117 leftColor->setAnchorPoint(Vec2(0,0.5));
118 center->setAnchorPoint(Vec2(0,0.5));
119 centerColor->setAnchorPoint(Vec2(0,0.5));
120 right->setAnchorPoint(Vec2(0,0.5));
121 rightColor->setAnchorPoint(Vec2(0,0.5));
122
123 top->setPosition(s.width/2,s.height-20);
124 left->setPosition(0,s.height/2);
125 leftColor->setPosition(left->getPosition());
126 center->setPosition(blockSize.width, s.height/2);
127 centerColor->setPosition(center->getPosition());
128 right->setPosition(blockSize.width*2, s.height/2);
129 rightColor->setPosition(right->getPosition());
130
131 this->addChild(leftColor, -1, kTagColor1);
132 this->addChild(left, 0, kTagLabel1);
133 this->addChild(rightColor, -1, kTagColor2);
134 this->addChild(right, 0, kTagLabel2);
135 this->addChild(centerColor, -1, kTagColor3);
136 this->addChild(center, 0, kTagLabel3);
137 this->addChild(top, 0, kTagLabel4);
138}
static TextVAlignment verticalAlignment[]
Definition: FontTest.cpp:55
static int vAlignIdx
Definition: FontTest.cpp:54
@ kTagColor1
Definition: FontTest.cpp:38
@ kTagLabel4
Definition: FontTest.cpp:36
@ kTagColor2
Definition: FontTest.cpp:39
@ kTagLabel1
Definition: FontTest.cpp:33
@ kTagLabel3
Definition: FontTest.cpp:35
@ kTagLabel2
Definition: FontTest.cpp:34
@ kTagColor3
Definition: FontTest.cpp:40

引用了 kTagColor1, kTagColor2, kTagColor3, kTagLabel1, kTagLabel2, kTagLabel3, kTagLabel4, vAlignIdx , 以及 verticalAlignment.

被这些函数引用 create().

+ 这是这个函数的调用关系图:

◆ title()

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

重载 TestCase .

在文件 FontTest.cpp140 行定义.

141{
142 return "Font test";
143}

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