PuzzleSDK
UIScrollViewTest_Horizontal类 参考

#include <UIScrollViewTest.h>

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

Public 成员函数

 CREATE_FUNC (UIScrollViewTest_Horizontal)
 
 UIScrollViewTest_Horizontal ()
 
 ~UIScrollViewTest_Horizontal ()
 
virtual bool init () override
 
- 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
 

详细描述

在文件 UIScrollViewTest.h47 行定义.

构造及析构函数说明

◆ UIScrollViewTest_Horizontal()

UIScrollViewTest_Horizontal::UIScrollViewTest_Horizontal ( )

在文件 UIScrollViewTest.cpp125 行定义.

126: _displayValueLabel(nullptr)
127{
128}
cocos2d::ui::Text * _displayValueLabel

◆ ~UIScrollViewTest_Horizontal()

UIScrollViewTest_Horizontal::~UIScrollViewTest_Horizontal ( )

在文件 UIScrollViewTest.cpp130 行定义.

131{
132}

成员函数说明

◆ CREATE_FUNC()

UIScrollViewTest_Horizontal::CREATE_FUNC ( UIScrollViewTest_Horizontal  )

◆ init()

bool UIScrollViewTest_Horizontal::init ( )
overridevirtual

重载 UIScene .

在文件 UIScrollViewTest.cpp134 行定义.

135{
136 if (UIScene::init())
137 {
138 Size widgetSize = _widget->getContentSize();
139
140 // Add a label in which the scrollview alert will be displayed
141 _displayValueLabel = Text::create("Move by horizontal direction","fonts/Marker Felt.ttf",32);
142 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
143 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
144 _uiLayer->addChild(_displayValueLabel);
145
146 Text* alert = Text::create("ScrollView horizontal","fonts/Marker Felt.ttf",30);
147 alert->setColor(Color3B(159, 168, 176));
148 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
149 _uiLayer->addChild(alert);
150
151 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
152
153 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
154
155 // Create the scrollview by horizontal
156 ui::ScrollView* scrollView = ui::ScrollView::create();
157 scrollView->setBounceEnabled(true);
158 scrollView->setDirection(ui::ScrollView::Direction::HORIZONTAL);
159 scrollView->setContentSize(Size(280.0f, 150.0f));
160 scrollView->setInnerContainerSize(scrollView->getContentSize());
161 scrollView->setScrollBarPositionFromCorner(Vec2(4, 4));
162 scrollView->setScrollBarColor(Color3B::YELLOW);
163 Size backgroundSize = background->getContentSize();
164 scrollView->setPosition((widgetSize - scrollView->getContentSize()) / 2.0f);
165 _uiLayer->addChild(scrollView);
166
167 ImageView* imageView = ImageView::create("cocosui/ccicon.png");
168
169 float innerWidth = scrollView->getContentSize().width + imageView->getContentSize().width;
170 float innerHeight = scrollView->getContentSize().height;
171
172 scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
173
174 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
175 button->setPosition(Vec2(button->getContentSize().width / 2.0f,
176 scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
177 scrollView->addChild(button);
178
179 Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
180 titleButton->setTitleText("Title Button");
181 titleButton->setPosition(Vec2(button->getRightBoundary() + button->getContentSize().width / 2.0f,
182 button->getBottomBoundary() - button->getContentSize().height / 2.0f));
183 scrollView->addChild(titleButton);
184
185 Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
186 button_scale9->setScale9Enabled(true);
187 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
188 button_scale9->setPosition(Vec2(titleButton->getRightBoundary() + titleButton->getContentSize().width / 2.0f,
189 titleButton->getBottomBoundary() - titleButton->getContentSize().height / 2.0f));
190 scrollView->addChild(button_scale9);
191
192 imageView->setPosition(Vec2(innerWidth - imageView->getContentSize().width / 2.0f,
193 button_scale9->getBottomBoundary() - button_scale9->getContentSize().height / 2.0f));
194 scrollView->addChild(imageView);
195
196 // Jump to right
197 scrollView->jumpToRight();
198
199 return true;
200 }
201
202 return false;
203}
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().

+ 函数调用图:

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIScrollViewTest_Horizontal::_displayValueLabel
protected

在文件 UIScrollViewTest.h58 行定义.

被这些函数引用 init().


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