PuzzleSDK
UILabelTest_Effect类 参考

#include <UITextTest.h>

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

Public 成员函数

 CREATE_FUNC (UILabelTest_Effect)
 
virtual bool init () override
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
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
 

额外继承的成员函数

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

详细描述

在文件 UITextTest.h50 行定义.

成员函数说明

◆ CREATE_FUNC()

UILabelTest_Effect::CREATE_FUNC ( UILabelTest_Effect  )

◆ init()

bool UILabelTest_Effect::init ( )
overridevirtual

重载 UIScene .

在文件 UITextTest.cpp118 行定义.

119{
120 if (UIScene::init())
121 {
122 Size widgetSize = _widget->getContentSize();
123
124 Text* alert = Text::create();
125 alert->setString("Label Effect");
126 alert->setFontName("fonts/Marker Felt.ttf");
127 alert->setFontSize(30);
128 alert->setColor(Color3B(159, 168, 176));
129 alert->setPosition(Vec2(widgetSize.width / 2.0f,
130 widgetSize.height / 2.0f
131 - alert->getContentSize().height * 3.05f));
132 _uiLayer->addChild(alert);
133
134
135 // create the shadow only label
136 Text* shadow_label = Text::create();
137
138 shadow_label->enableShadow();
139 shadow_label->setString("Shadow");
140 shadow_label->setFontName("fonts/Marker Felt.ttf");
141 shadow_label->setPosition(Vec2(widgetSize.width / 2.0f,
142 widgetSize.height / 2.0f
143 + shadow_label->getContentSize().height + 20));
144
145 _uiLayer->addChild(shadow_label);
146
147
148 // create the stroke only label
149 Text* glow_label = Text::create();
150 glow_label->setFontName("fonts/Marker Felt.ttf");
151 glow_label->setString("Glow");
152 glow_label->enableGlow(Color4B::RED);
153
154
155 glow_label->setPosition(Vec2(widgetSize.width / 2.0f,
156 widgetSize.height / 2.0f - 20));
157
158 _uiLayer->addChild(glow_label);
159
160
161 // create the label stroke and shadow
162 Text* outline_label = Text::create();
163 outline_label->setString("Outline");
164 CCLOG("content size without outline: %f %f",
165 outline_label->getContentSize().width,
166 outline_label->getContentSize().height);
167 outline_label->enableOutline(Color4B::GREEN, 4);
168 outline_label->setPosition(Vec2(widgetSize.width / 2.0f,
169 widgetSize.height / 2.0f
170 - shadow_label->getContentSize().height - 50));
171
172 _uiLayer->addChild(outline_label);
173 CCLOG("content size after applying outline: %f %f",
174 outline_label->getContentSize().width,
175 outline_label->getContentSize().height);
176
177 //create buttons to disable effect and add
178 auto disableOutlineBtn= Button::create();
179 disableOutlineBtn->setTitleText("Disable outline");
180 disableOutlineBtn->setTitleFontName("fonts/Marker Felt.ttf");
181 disableOutlineBtn->setPosition(Vec2(widgetSize.width * 0.3f,
182 widgetSize.height * 0.7f));
183 disableOutlineBtn->setPressedActionEnabled(true);
184 disableOutlineBtn->addClickEventListener([=](Ref*){
185 outline_label->disableEffect(LabelEffect::OUTLINE);
186 CCLOG("content size after disable outline: %f %f",
187 outline_label->getContentSize().width,
188 outline_label->getContentSize().height);
189 });
190 this->addChild(disableOutlineBtn);
191
192 auto buttonWidth = disableOutlineBtn->getContentSize().width;
193
194 auto disableGlowBtn = (Button*)disableOutlineBtn->clone();
195 disableGlowBtn->setPosition(disableOutlineBtn->getPosition()
196 + Vec2(buttonWidth + 40,0.0f));
197 disableGlowBtn->setTitleText("Disable Glow");
198 disableGlowBtn->addClickEventListener([=](Ref*){
199 glow_label->disableEffect(LabelEffect::GLOW);
200 });
201 this->addChild(disableGlowBtn);
202
203 auto disableShadowBtn = (Button*)disableGlowBtn->clone();
204 disableShadowBtn->setPosition(disableGlowBtn->getPosition()
205 + Vec2(buttonWidth + 40,0.0f));
206 disableShadowBtn->setTitleText("Disable Shadow");
207 disableShadowBtn->addClickEventListener([=](Ref*){
208 shadow_label->disableEffect(LabelEffect::SHADOW);
209 });
210 this->addChild(disableShadowBtn);
211
212
213 return true;
214 }
215 return false;
216}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 UIScene::_uiLayer, UIScene::_widget , 以及 UIScene::init().

+ 函数调用图:

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