PuzzleSDK
UIScrollViewTest_Vertical类 参考

#include <UIScrollViewTest.h>

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

Public 成员函数

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

构造及析构函数说明

◆ UIScrollViewTest_Vertical()

UIScrollViewTest_Vertical::UIScrollViewTest_Vertical ( )

在文件 UIScrollViewTest.cpp46 行定义.

47: _displayValueLabel(nullptr)
48{
49}
cocos2d::ui::Text * _displayValueLabel

◆ ~UIScrollViewTest_Vertical()

UIScrollViewTest_Vertical::~UIScrollViewTest_Vertical ( )

在文件 UIScrollViewTest.cpp51 行定义.

52{
53}

成员函数说明

◆ CREATE_FUNC()

UIScrollViewTest_Vertical::CREATE_FUNC ( UIScrollViewTest_Vertical  )

◆ init()

bool UIScrollViewTest_Vertical::init ( )
overridevirtual

重载 UIScene .

在文件 UIScrollViewTest.cpp55 行定义.

56{
57 if (UIScene::init())
58 {
59 Size widgetSize = _widget->getContentSize();
60
61 // Add a label in which the scrollview alert will be displayed
62 _displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
63 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
64 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
65 widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
67
68 // Add the alert
69 Text* alert = Text::create("ScrollView vertical", "fonts/Marker Felt.ttf", 30);
70 alert->setColor(Color3B(159, 168, 176));
71 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
72 _uiLayer->addChild(alert);
73
74 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
75
76 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
77
78 // Create the scrollview by vertical
79 ui::ScrollView* scrollView = ui::ScrollView::create();
80 scrollView->setContentSize(Size(280.0f, 100.0f));
81 Size backgroundSize = background->getContentSize();
82 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
83 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
84 (widgetSize.height - backgroundSize.height) / 2.0f +
85 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
86 scrollView->setScrollBarWidth(4);
87 scrollView->setScrollBarPositionFromCorner(Vec2(2, 2));
88 scrollView->setScrollBarColor(Color3B::WHITE);
89 scrollView->setGlobalZOrder(200);
90 _uiLayer->addChild(scrollView);
91
92 ImageView* imageView = ImageView::create("cocosui/ccicon.png");
93
94 float innerWidth = scrollView->getContentSize().width;
95 float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
96
97 scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
98
99 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
100 button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
101 scrollView->addChild(button);
102
103 Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
104 titleButton->setTitleText("Title Button");
105 titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
106 scrollView->addChild(titleButton);
107
108 Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
109 button_scale9->setScale9Enabled(true);
110 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
111 button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
112 scrollView->addChild(button_scale9);
113
114 imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
115 scrollView->addChild(imageView);
116 scrollView->scrollToBottom(2.0, true);
117 return true;
118 }
119
120 return false;
121}
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_Vertical::_displayValueLabel
protected

在文件 UIScrollViewTest.h44 行定义.

被这些函数引用 init().


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