PuzzleSDK
UISliderTest类 参考

#include <UISliderTest.h>

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

Public 成员函数

 CREATE_FUNC (UISliderTest)
 
 UISliderTest ()
 
 ~UISliderTest ()
 
virtual bool init () override
 
void sliderEvent (cocos2d::Ref *sender, cocos2d::ui::Slider::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::TextBMFont * _displayValueLabel
 
cocos2d::ui::Slider * _slider
 
- 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
 

详细描述

在文件 UISliderTest.h33 行定义.

构造及析构函数说明

◆ UISliderTest()

UISliderTest::UISliderTest ( )

在文件 UISliderTest.cpp43 行定义.

44: _displayValueLabel(nullptr)
45{
46
47}
cocos2d::ui::TextBMFont * _displayValueLabel
Definition: UISliderTest.h:45

◆ ~UISliderTest()

UISliderTest::~UISliderTest ( )

在文件 UISliderTest.cpp49 行定义.

50{
51}

成员函数说明

◆ CREATE_FUNC()

UISliderTest::CREATE_FUNC ( UISliderTest  )

◆ init()

bool UISliderTest::init ( )
overridevirtual

重载 UIScene .

在文件 UISliderTest.cpp53 行定义.

54{
55 if (UIScene::init())
56 {
57 Size widgetSize = _widget->getContentSize();
58
59 // Add a label in which the slider alert will be displayed
60 _displayValueLabel = TextBMFont::create("Move the slider thumb", "ccb/markerfelt24shadow.fnt");
61 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
62 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
64
65 // Add the alert
66 Text* alert = Text::create("Slider","fonts/Marker Felt.ttf",30);
67 alert->setColor(Color3B(159, 168, 176));
68 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
69 _uiLayer->addChild(alert);
70
71 // Create the slider
72 Slider* slider = Slider::create();
73 slider->loadBarTexture("cocosui/sliderTrack.png");
74 slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
75 slider->loadProgressBarTexture("cocosui/sliderProgress.png");
76 slider->setMaxPercent(10000);
77 slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 2.0f*/));
78 slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this));
79 _uiLayer->addChild(slider);
80
81 _slider = slider;
82
83 TTFConfig ttfConfig("fonts/arial.ttf", 15);
84 auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
85 auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printWidgetResources, this));
86 item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
87 auto pMenu1 = Menu::create(item1, nullptr);
88 pMenu1->setPosition(Vec2(0.0f, 0.0f));
89 this->addChild(pMenu1, 10);
90
91 return true;
92 }
93 return false;
94}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45
void sliderEvent(cocos2d::Ref *sender, cocos2d::ui::Slider::EventType type)
void printWidgetResources(cocos2d::Ref *sender)
cocos2d::ui::Slider * _slider
Definition: UISliderTest.h:46
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45

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

+ 函数调用图:

◆ printWidgetResources()

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

在文件 UISliderTest.cpp106 行定义.

107{
108 cocos2d::ResourceData textureFile = _slider->getBackFile();
109 CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
110 cocos2d::ResourceData progressBarTextureFile = _slider->getProgressBarFile();
111 CCLOG("progressBarTextureFile Name : %s, Type: %d", progressBarTextureFile.file.c_str(), progressBarTextureFile.type);
112 cocos2d::ResourceData slidBallNormalTextureFile = _slider->getBallNormalFile();
113 CCLOG("slidBallNormalTextureFile Name : %s, Type: %d", slidBallNormalTextureFile.file.c_str(), slidBallNormalTextureFile.type);
114 cocos2d::ResourceData slidBallPressedTextureFile = _slider->getBallPressedFile();
115 CCLOG("slidBallPressedTextureFile Name : %s, Type: %d", slidBallPressedTextureFile.file.c_str(), slidBallPressedTextureFile.type);
116 cocos2d::ResourceData slidBallDisabledTextureFile = _slider->getBallDisabledFile();
117 CCLOG("slidBallDisabledTextureFile Name : %s, Type: %d", slidBallDisabledTextureFile.file.c_str(), slidBallDisabledTextureFile.type);
118}

引用了 _slider.

被这些函数引用 init().

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

◆ sliderEvent()

void UISliderTest::sliderEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Slider::EventType  type 
)

在文件 UISliderTest.cpp96 行定义.

97{
98 if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
99 {
100 Slider* slider = dynamic_cast<Slider*>(pSender);
101 int percent = slider->getPercent();
102 int maxPercent = slider->getMaxPercent();
103 _displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent));
104 }
105}

引用了 _displayValueLabel.

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::TextBMFont* UISliderTest::_displayValueLabel
protected

在文件 UISliderTest.h45 行定义.

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

◆ _slider

cocos2d::ui::Slider* UISliderTest::_slider
protected

在文件 UISliderTest.h46 行定义.

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


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