PuzzleSDK
UIPageViewTest类 参考

#include <UIPageViewTest.h>

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

Public 成员函数

 CREATE_FUNC (UIPageViewTest)
 
 UIPageViewTest ()
 
 ~UIPageViewTest ()
 
virtual bool init () override
 
void pageViewEvent (cocos2d::Ref *sender, cocos2d::ui::PageView::EventType type)
 
- 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
 

详细描述

在文件 UIPageViewTest.h33 行定义.

构造及析构函数说明

◆ UIPageViewTest()

UIPageViewTest::UIPageViewTest ( )

在文件 UIPageViewTest.cpp45 行定义.

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

◆ ~UIPageViewTest()

UIPageViewTest::~UIPageViewTest ( )

在文件 UIPageViewTest.cpp51 行定义.

52{
53}

成员函数说明

◆ CREATE_FUNC()

UIPageViewTest::CREATE_FUNC ( UIPageViewTest  )

◆ init()

bool UIPageViewTest::init ( )
overridevirtual

重载 UIScene .

在文件 UIPageViewTest.cpp55 行定义.

56{
57 if (UIScene::init())
58 {
59 Size widgetSize = _widget->getContentSize();
60
61 // Add a label in which the dragpanel events will be displayed
62 _displayValueLabel = Text::create("Move by horizontal 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 +
66 _displayValueLabel->getContentSize().height * 1.5));
68
69 // Add the black background
70 Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
71 alert->setColor(Color3B(159, 168, 176));
72 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
73 _uiLayer->addChild(alert);
74
75 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
76
77 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
78
79 // Create the page view
80 Size size(240, 130);
81 PageView* pageView = PageView::create();
82 pageView->setDirection(PageView::Direction::HORIZONTAL);
83 pageView->setContentSize(size);
84 Size backgroundSize = background->getContentSize();
85 pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f);
86 pageView->removeAllItems();
87 pageView->setIndicatorEnabled(true);
88 pageView->setGlobalZOrder(200);
89
90 int pageCount = 4;
91 for (int i = 0; i < pageCount; ++i)
92 {
93 Layout* layout = Layout::create();
94 layout->setContentSize(size);
95
96 ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
97 imageView->setScale9Enabled(true);
98 imageView->setContentSize(size);
99 imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
100 layout->addChild(imageView);
101
102 Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
103 label->setColor(Color3B(192, 192, 192));
104 label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
105 layout->addChild(label);
106
107 pageView->insertCustomItem(layout, i);
108 }
109
110 pageView->removeItem(0);
111 pageView->scrollToItem(pageCount - 2);
112
113 cocos2d::log("TODO in %s %s %d", __FILE__, __FUNCTION__, __LINE__);
114
115 pageView->setIndicatorIndexNodesOpacity(255);
116
117 _uiLayer->addChild(pageView);
118
119 return true;
120 }
121 return false;
122}
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().

+ 函数调用图:

◆ pageViewEvent()

void UIPageViewTest::pageViewEvent ( cocos2d::Ref *  sender,
cocos2d::ui::PageView::EventType  type 
)

在文件 UIPageViewTest.cpp124 行定义.

125{
126 switch (type)
127 {
128 case PageView::EventType::TURNING:
129 {
130 PageView* pageView = dynamic_cast<PageView*>(pSender);
131
132 _displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
133 }
134 break;
135
136 default:
137 break;
138 }
139}

引用了 _displayValueLabel.

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIPageViewTest::_displayValueLabel
protected

在文件 UIPageViewTest.h46 行定义.

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


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