PuzzleSDK
UICheckBoxTest类 参考

#include <UICheckBoxTest.h>

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

Public 成员函数

 CREATE_FUNC (UICheckBoxTest)
 
 UICheckBoxTest ()
 
 ~UICheckBoxTest ()
 
virtual bool init () override
 
void selectedEvent (cocos2d::Ref *sender, cocos2d::ui::CheckBox::EventType type)
 
void printWidgetResources (cocos2d::Ref *sender)
 
- 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
 
cocos2d::ui::CheckBox * _checkBox
 
- 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
 

详细描述

在文件 UICheckBoxTest.h33 行定义.

构造及析构函数说明

◆ UICheckBoxTest()

UICheckBoxTest::UICheckBoxTest ( )

在文件 UICheckBoxTest.cpp38 行定义.

39: _displayValueLabel(nullptr)
40{
41
42}
cocos2d::ui::Text * _displayValueLabel

◆ ~UICheckBoxTest()

UICheckBoxTest::~UICheckBoxTest ( )

在文件 UICheckBoxTest.cpp44 行定义.

45{
46}

成员函数说明

◆ CREATE_FUNC()

UICheckBoxTest::CREATE_FUNC ( UICheckBoxTest  )

◆ init()

bool UICheckBoxTest::init ( )
overridevirtual

重载 UIScene .

在文件 UICheckBoxTest.cpp48 行定义.

49{
50 if (UIScene::init())
51 {
52 Size widgetSize = _widget->getContentSize();
53
54 // Add a label in which the checkbox events will be displayed
55 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
56 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
57 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
59
60 // Add the alert
61 Text* alert = Text::create("CheckBox","fonts/Marker Felt.ttf",30 );
62 alert->setColor(Color3B(159, 168, 176));
63 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
64 _uiLayer->addChild(alert);
65
66 // Create the checkbox
67 _checkBox = CheckBox::create("cocosui/check_box_normal.png",
68 "cocosui/check_box_normal_press.png",
69 "cocosui/check_box_active.png",
70 "cocosui/check_box_normal_disable.png",
71 "cocosui/check_box_active_disable.png");
72 _checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
73
74 _checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this));
75 _uiLayer->addChild(_checkBox);
76
77 TTFConfig ttfConfig("fonts/arial.ttf", 15);
78 auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
79 auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printWidgetResources, this));
80 item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
81 auto pMenu1 = Menu::create(item1, nullptr);
82 pMenu1->setPosition(Vec2(0.0f, 0.0f));
83 this->addChild(pMenu1, 10);
84
85 return true;
86 }
87 return false;
88}
void selectedEvent(cocos2d::Ref *sender, cocos2d::ui::CheckBox::EventType type)
cocos2d::ui::CheckBox * _checkBox
void printWidgetResources(cocos2d::Ref *sender)
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45

引用了 _checkBox, _displayValueLabel, UIScene::_uiLayer, UIScene::_widget, VisibleRect::bottom(), UIScene::init(), VisibleRect::left(), printWidgetResources() , 以及 selectedEvent().

+ 函数调用图:

◆ printWidgetResources()

void UICheckBoxTest::printWidgetResources ( cocos2d::Ref *  sender)

在文件 UICheckBoxTest.cpp108 行定义.

109{
110 cocos2d::ResourceData backGroundFileName = _checkBox->getBackNormalFile();
111 CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type);
112 cocos2d::ResourceData backGroundSelectedFileName = _checkBox->getBackPressedFile();
113 CCLOG("backGroundSelectedFile Name : %s, Type: %d", backGroundSelectedFileName.file.c_str(), backGroundSelectedFileName.type);
114 cocos2d::ResourceData backGroundDisabledFileName = _checkBox->getBackDisabledFile();
115 CCLOG("backGroundDisabledFile Name : %s, Type: %d", backGroundDisabledFileName.file.c_str(), backGroundDisabledFileName.type);
116 cocos2d::ResourceData frontCrossFileName = _checkBox->getCrossNormalFile();
117 CCLOG("frontCrossFile Name : %s, Type: %d", frontCrossFileName.file.c_str(), frontCrossFileName.type);
118 cocos2d::ResourceData frontCrossDisabledFileName = _checkBox->getCrossDisabledFile();
119 CCLOG("frontCrossDisabledFile Name : %s, Type: %d", frontCrossDisabledFileName.file.c_str(), frontCrossDisabledFileName.type);
120}

引用了 _checkBox.

被这些函数引用 init().

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

◆ selectedEvent()

void UICheckBoxTest::selectedEvent ( cocos2d::Ref *  sender,
cocos2d::ui::CheckBox::EventType  type 
)

在文件 UICheckBoxTest.cpp90 行定义.

91{
92 switch (type)
93 {
94 case CheckBox::EventType::SELECTED:
95 _displayValueLabel->setString(StringUtils::format("Selected"));
96 break;
97
98 case CheckBox::EventType::UNSELECTED:
99 _displayValueLabel->setString(StringUtils::format("Unselected"));
100 break;
101
102 default:
103 break;
104 }
105
106}

引用了 _displayValueLabel.

被这些函数引用 init().

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

类成员变量说明

◆ _checkBox

cocos2d::ui::CheckBox* UICheckBoxTest::_checkBox
protected

在文件 UICheckBoxTest.h47 行定义.

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

◆ _displayValueLabel

cocos2d::ui::Text* UICheckBoxTest::_displayValueLabel
protected

在文件 UICheckBoxTest.h46 行定义.

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


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