PuzzleSDK
UIButtonTest_Scale9_State_Change类 参考

#include <UIButtonTest.h>

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

Public 成员函数

 CREATE_FUNC (UIButtonTest_Scale9_State_Change)
 
 UIButtonTest_Scale9_State_Change ()
 
 ~UIButtonTest_Scale9_State_Change ()
 
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.h65 行定义.

构造及析构函数说明

◆ UIButtonTest_Scale9_State_Change()

UIButtonTest_Scale9_State_Change::UIButtonTest_Scale9_State_Change ( )

在文件 UIButtonTest.cpp257 行定义.

258 : _displayValueLabel(nullptr)
259{
260
261}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:77

◆ ~UIButtonTest_Scale9_State_Change()

UIButtonTest_Scale9_State_Change::~UIButtonTest_Scale9_State_Change ( )

在文件 UIButtonTest.cpp263 行定义.

264{
265
266}

成员函数说明

◆ CREATE_FUNC()

UIButtonTest_Scale9_State_Change::CREATE_FUNC ( UIButtonTest_Scale9_State_Change  )

◆ init()

bool UIButtonTest_Scale9_State_Change::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp268 行定义.

269{
270 if (UIScene::init())
271 {
272 Size widgetSize = _widget->getContentSize();
273
274 // Add a label in which the button events will be displayed
275 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
276 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
277 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
278 _uiLayer->addChild(_displayValueLabel);
279
280 // Add the alert
281 Text* alert = Text::create("Button scale9 render", "fonts/Marker Felt.ttf", 30);
282 alert->setColor(Color3B(159, 168, 176));
283 alert->setPosition(Vec2(widgetSize.width / 2.0f,
284 widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
285 _uiLayer->addChild(alert);
286
287 // Create the button
288 Button* button = Button::create("cocosui/button.png");
289 // open scale9 render
290 button->ignoreContentAdaptWithSize(false);
291 button->setScale9Enabled(true);
292 button->setPosition(Vec2(widgetSize.width / 2.0f - 100, widgetSize.height / 2.0f));
293 button->setContentSize(Size(180.0f, 60.0f));
294 button->setTitleText("Hello Scale9");
295 button->setPressedActionEnabled(false);
296 button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9_State_Change::touchEvent, this));
297 _uiLayer->addChild(button);
298
299 Button* button2 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
300 // open scale9 render
301 button2->ignoreContentAdaptWithSize(false);
302 button2->setScale9Enabled(true);
303 button2->setTitleText("Hello scale9");
304 button2->setPosition(Vec2(widgetSize.width / 2.0f + 100, widgetSize.height / 2.0f));
305 button2->setContentSize(Size(180.0f, 60.0f));
306 button2->setPressedActionEnabled(true);
307 button2->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9_State_Change::touchEvent, this));
308 _uiLayer->addChild(button2);
309 return true;
310 }
311 return false;
312}
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_State_Change::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIButtonTest.cpp314 行定义.

315{
316 switch (type)
317 {
318 case Widget::TouchEventType::BEGAN:
319 _displayValueLabel->setString(StringUtils::format("Touch Down"));
320 break;
321
322 case Widget::TouchEventType::MOVED:
323 _displayValueLabel->setString(StringUtils::format("Touch Move"));
324 break;
325
326 case Widget::TouchEventType::ENDED:
327 {
328 _displayValueLabel->setString(StringUtils::format("Touch Up"));
329 Button *btn = (Button*)pSender;
330 if (btn->isScale9Enabled())
331 {
332 btn->setScale9Enabled(false);
333 }
334 else
335 btn->setScale9Enabled(true);
336 }
337 break;
338
339 case Widget::TouchEventType::CANCELED:
340 _displayValueLabel->setString(StringUtils::format("Touch Cancelled"));
341 break;
342
343 default:
344 break;
345 }
346}

引用了 _displayValueLabel.

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTest_Scale9_State_Change::_displayValueLabel
protected

在文件 UIButtonTest.h77 行定义.

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


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