PuzzleSDK
UILoadingBarTest_Left类 参考

#include <UILoadingBarTest.h>

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

Public 成员函数

 CREATE_FUNC (UILoadingBarTest_Left)
 
 UILoadingBarTest_Left ()
 
 ~UILoadingBarTest_Left ()
 
virtual bool init () override
 
void update (float delta) override
 
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 属性

int _count
 
cocos2d::ui::LoadingBar * _loadingBar
 
- 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
 

详细描述

在文件 UILoadingBarTest.h33 行定义.

构造及析构函数说明

◆ UILoadingBarTest_Left()

UILoadingBarTest_Left::UILoadingBarTest_Left ( )

在文件 UILoadingBarTest.cpp44 行定义.

45: _count(0)
46{
47
48}

◆ ~UILoadingBarTest_Left()

UILoadingBarTest_Left::~UILoadingBarTest_Left ( )

在文件 UILoadingBarTest.cpp50 行定义.

51{
52 unscheduleUpdate();
53}

成员函数说明

◆ CREATE_FUNC()

UILoadingBarTest_Left::CREATE_FUNC ( UILoadingBarTest_Left  )

◆ init()

bool UILoadingBarTest_Left::init ( )
overridevirtual

重载 UIScene .

在文件 UILoadingBarTest.cpp55 行定义.

56{
57 if (UIScene::init())
58 {
59 scheduleUpdate();
60
61 Size widgetSize = _widget->getContentSize();
62
63 // Add the alert
64 Text* alert = Text::create("Test LoadingBar Change Direction",
65 "fonts/Marker Felt.ttf", 30);
66 alert->setColor(Color3B(159, 168, 176));
67 alert->setPosition(Vec2(widgetSize.width / 2.0f,
68 widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
69 _uiLayer->addChild(alert);
70
71 // Create the loading bar
72 LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
73 loadingBar->setTag(0);
74 loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
75 widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
76
77 auto loadingBarCopy = (LoadingBar*)loadingBar->clone();
78 loadingBarCopy->setTag(1);
79 loadingBarCopy->setPosition(loadingBar->getPosition()
80 + Vec2(0, -40));
81 loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT);
82
83 Button* button = Button::create("cocosui/animationbuttonnormal.png",
84 "cocosui/animationbuttonpressed.png");
85 button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 50));
86 button->setTitleText("Click to change direction!");
87
88 button->addTouchEventListener([=](Ref*, Widget::TouchEventType type)
89 {
90 if (type == Widget::TouchEventType::ENDED)
91 {
92 if (loadingBar->getDirection() == LoadingBar::Direction::LEFT)
93 {
94 loadingBar->setDirection(LoadingBar::Direction::RIGHT);
95 loadingBarCopy->setDirection(LoadingBar::Direction::LEFT);
96 }
97 else
98 {
99 loadingBar->setDirection(LoadingBar::Direction::LEFT);
100 loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT);
101 }
102 }
103 });
104 _uiLayer->addChild(loadingBar,1);
105 _uiLayer->addChild(loadingBarCopy,2);
106 _uiLayer->addChild(button);
107
108 _loadingBar = loadingBar;
109
110 TTFConfig ttfConfig("fonts/arial.ttf", 15);
111 auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
112 auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printWidgetResources, this));
113 item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
114 auto pMenu1 = Menu::create(item1, nullptr);
115 pMenu1->setPosition(Vec2(0, 0));
116 this->addChild(pMenu1, 10);
117
118 return true;
119 }
120 return false;
121}
void printWidgetResources(cocos2d::Ref *sender)
cocos2d::ui::LoadingBar * _loadingBar
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

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

+ 函数调用图:

◆ printWidgetResources()

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

在文件 UILoadingBarTest.cpp136 行定义.

137{
138 cocos2d::ResourceData textureFile = _loadingBar->getRenderFile();
139 CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
140}

引用了 _loadingBar.

被这些函数引用 init().

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

◆ update()

void UILoadingBarTest_Left::update ( float  delta)
override

在文件 UILoadingBarTest.cpp123 行定义.

124{
125 _count++;
126 if (_count > 100)
127 {
128 _count = 0;
129 }
130 LoadingBar* loadingBar = static_cast<LoadingBar*>(_uiLayer->getChildByTag(0));
131 LoadingBar* loadingBarCopy = static_cast<LoadingBar*>(_uiLayer->getChildByTag(1));
132 loadingBar->setPercent(_count);
133 loadingBarCopy->setPercent(_count);
134}

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

类成员变量说明

◆ _count

int UILoadingBarTest_Left::_count
protected

在文件 UILoadingBarTest.h45 行定义.

被这些函数引用 update().

◆ _loadingBar

cocos2d::ui::LoadingBar* UILoadingBarTest_Left::_loadingBar
protected

在文件 UILoadingBarTest.h46 行定义.

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


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