PuzzleSDK
UIButtonTestSwitchScale9类 参考

#include <UIButtonTest.h>

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

Public 成员函数

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

构造及析构函数说明

◆ UIButtonTestSwitchScale9()

UIButtonTestSwitchScale9::UIButtonTestSwitchScale9 ( )

在文件 UIButtonTest.cpp622 行定义.

623: _displayValueLabel(nullptr)
624{
625
626}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:137

◆ ~UIButtonTestSwitchScale9()

UIButtonTestSwitchScale9::~UIButtonTestSwitchScale9 ( )

在文件 UIButtonTest.cpp628 行定义.

629{
630}

成员函数说明

◆ CREATE_FUNC()

UIButtonTestSwitchScale9::CREATE_FUNC ( UIButtonTestSwitchScale9  )

◆ init()

bool UIButtonTestSwitchScale9::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp632 行定义.

633{
634 if (UIScene::init())
635 {
636 Size widgetSize = _widget->getContentSize();
637
638 // Add a label in which the button events will be displayed
639 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
640 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
641 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
642 _uiLayer->addChild(_displayValueLabel);
643
644
645 // Create the button
646 Button* button = Button::create("cocosui/animationbuttonnormal.png",
647 "cocosui/animationbuttonpressed.png");
648 button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
649 button->addTouchEventListener(CC_CALLBACK_2(UIButtonTestSwitchScale9::touchEvent, this));
650 button->setTitleText("Button Title");
651 button->ignoreContentAdaptWithSize(false);
652
653 _uiLayer->addChild(button);
654
655
656
657 return true;
658 }
659 return false;
660}
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 UIButtonTestSwitchScale9::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIButtonTest.cpp662 行定义.

663{
664 switch (type)
665 {
666 case Widget::TouchEventType::BEGAN:
667 _displayValueLabel->setString(StringUtils::format("Touch Down"));
668 break;
669
670 case Widget::TouchEventType::MOVED:
671 _displayValueLabel->setString(StringUtils::format("Touch Move"));
672 break;
673
674 case Widget::TouchEventType::ENDED:
675 {
676 _displayValueLabel->setString(StringUtils::format("Touch Up"));
677 auto btn = ((Button*)pSender);
678 btn->setScale9Enabled(!btn->isScale9Enabled());
679 btn->setContentSize(Size(200.0f,100.0f));
680 }
681 break;
682
683 case Widget::TouchEventType::CANCELED:
684 _displayValueLabel->setString(StringUtils::format("Touch Cancelled"));
685 break;
686
687 default:
688 break;
689 }
690}

引用了 _displayValueLabel.

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTestSwitchScale9::_displayValueLabel
protected

在文件 UIButtonTest.h137 行定义.

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


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