PuzzleSDK
UIButtonTest_Scale9类 参考

#include <UIButtonTest.h>

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

Public 成员函数

 CREATE_FUNC (UIButtonTest_Scale9)
 
 UIButtonTest_Scale9 ()
 
 ~UIButtonTest_Scale9 ()
 
virtual bool init () override
 
void touchEvent (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
 
- 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
 

Protected 属性

cocos2d::ui::Text * _displayValueLabel
 
- 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
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 UIButtonTest.h50 行定义.

构造及析构函数说明

◆ UIButtonTest_Scale9()

UIButtonTest_Scale9::UIButtonTest_Scale9 ( )

在文件 UIButtonTest.cpp167 行定义.

168: _displayValueLabel(nullptr)
169{
170
171}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:62

◆ ~UIButtonTest_Scale9()

UIButtonTest_Scale9::~UIButtonTest_Scale9 ( )

在文件 UIButtonTest.cpp173 行定义.

174{
175
176}

成员函数说明

◆ CREATE_FUNC()

UIButtonTest_Scale9::CREATE_FUNC ( UIButtonTest_Scale9  )

◆ init()

bool UIButtonTest_Scale9::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp178 行定义.

179{
180 if (UIScene::init())
181 {
182 Size widgetSize = _widget->getContentSize();
183
184 // Add a label in which the button events will be displayed
185 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
186 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
187 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
188 _uiLayer->addChild(_displayValueLabel);
189
190 // Add the alert
191 Text* alert = Text::create("Button scale9 render", "fonts/Marker Felt.ttf",30);
192 alert->setColor(Color3B(159, 168, 176));
193 alert->setPosition(Vec2(widgetSize.width / 2.0f,
194 widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
195 _uiLayer->addChild(alert);
196
197 // Create the button
198 Button* button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
199 // open scale9 render
200 button->setScale9Enabled(true);
201 button->setContentSize(Size(150.0f, 70.0f));
202 button->setPosition(Vec2(-button->getContentSize().width - 10, widgetSize.height / 2.0f));
203 auto moveBy = MoveBy::create(1.0f, Vec2(widgetSize.width/2, 0.0f));
204 auto moveByReverse = moveBy->reverse()->clone();
205 button->runAction(RepeatForever::create(
206 Sequence::create(moveBy,moveByReverse, NULL)));
207 button->setPressedActionEnabled(true);
208 button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9::touchEvent, this));
209 _uiLayer->addChild(button);
210
211 // Create the imageview
212 Button* button2 = Button::create();
213 button2->setPosition(Vec2(widgetSize.width / 2.0f + button->getContentSize().width + 20, widgetSize.height / 2.0f));
214 button2->setName("normal");
215 _uiLayer->addChild(button2);
216
217 Sprite *sprite = Sprite::create("cocosui/animationbuttonnormal.png");
218 button2->addChild(sprite);
219
220 return true;
221 }
222 return false;
223}
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

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

+ 函数调用图:

◆ touchEvent()

void UIButtonTest_Scale9::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIButtonTest.cpp225 行定义.

226{
227 switch (type)
228 {
229 case Widget::TouchEventType::BEGAN:
230 _displayValueLabel->setString(StringUtils::format("Touch Down"));
231 break;
232
233 case Widget::TouchEventType::MOVED:
234 _displayValueLabel->setString(StringUtils::format("Touch Move"));
235 break;
236
237 case Widget::TouchEventType::ENDED:
238 {
239 _displayValueLabel->setString(StringUtils::format("Touch Up"));
240 Button *btn = (Button*)_uiLayer->getChildByName("normal");
241 btn->loadTextureNormal("cocosui/animationbuttonnormal.png");
242 btn->loadTexturePressed("cocosui/animationbuttonpressed.png");
243 btn->runAction(Sequence::create(FadeIn::create(0.5),DelayTime::create(1.0),FadeOut::create(0.5), nullptr));
244 }
245 break;
246
247 case Widget::TouchEventType::CANCELED:
248 _displayValueLabel->setString(StringUtils::format("Touch Cancelled"));
249 break;
250
251 default:
252 break;
253 }
254}

引用了 _displayValueLabel , 以及 UIScene::_uiLayer.

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTest_Scale9::_displayValueLabel
protected

在文件 UIButtonTest.h62 行定义.

被这些函数引用 init() , 以及 touchEvent().


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