PuzzleSDK
UIScrollViewTestEvents类 参考

#include <UIScrollViewTest.h>

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

Public 成员函数

 CREATE_FUNC (UIScrollViewTestEvents)
 
 UIScrollViewTestEvents ()
 
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.h159 行定义.

构造及析构函数说明

◆ UIScrollViewTestEvents()

UIScrollViewTestEvents::UIScrollViewTestEvents ( )

在文件 UIScrollViewTest.cpp714 行定义.

715 : _displayValueLabel(nullptr)
716{
717
718}
cocos2d::ui::Text * _displayValueLabel

成员函数说明

◆ CREATE_FUNC()

UIScrollViewTestEvents::CREATE_FUNC ( UIScrollViewTestEvents  )

◆ init()

bool UIScrollViewTestEvents::init ( )
overridevirtual

重载 UIScene .

在文件 UIScrollViewTest.cpp720 行定义.

721{
722 if (UIScene::init())
723 {
724 Size widgetSize = _widget->getContentSize();
725
726 // Add a label in which the dragpanel events will be displayed
727 _displayValueLabel = Text::create("(no events)","fonts/Marker Felt.ttf",32);
728 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
729 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
730 _uiLayer->addChild(_displayValueLabel);
731
732 // Add the alert
733 Text* alert = Text::create("ScrollView events","fonts/Marker Felt.ttf",30);
734 alert->setColor(Color3B(159, 168, 176));
735 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
736 _uiLayer->addChild(alert);
737
738 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
739
740 Layout* background = static_cast<Layout*>(root->getChildByName("background_Panel"));
741
742 // Create the dragpanel
743 ui::ScrollView* scrollView = ui::ScrollView::create();
744 scrollView->setDirection(ui::ScrollView::Direction::BOTH);
745 scrollView->setTouchEnabled(true);
746 scrollView->setBounceEnabled(true);
747 scrollView->setBackGroundImageScale9Enabled(true);
748 scrollView->setBackGroundImage("cocosui/green_edit.png");
749 scrollView->setContentSize(Size(210, 122.5));
750 scrollView->setScrollBarWidth(4);
751 scrollView->setScrollBarPositionFromCorner(Vec2(6, 6));
752 Size backgroundSize = background->getContentSize();
753 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
754 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
755 (widgetSize.height - backgroundSize.height) / 2.0f +
756 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
757 ImageView* imageView = ImageView::create("Hello.png");
758 scrollView->addChild(imageView);
759
760 scrollView->setInnerContainerSize(imageView->getContentSize());
761 Size innerSize = scrollView->getInnerContainerSize();
762 imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
763
764 _uiLayer->addChild(scrollView);
765
766 // Jump to right bottom
767 scrollView->jumpToBottomRight();
768
769 auto getRandomColor = [] {
770 return Color4B(random(0, 255), random(0, 255), random(0, 255), 255);
771 };
772 scrollView->addEventListener([&](Ref*, ui::ScrollView::EventType e) {
773 switch ( e ) {
774 case ui::ScrollView::EventType::SCROLLING_BEGAN:
775 _displayValueLabel->setString("scrolling began!");
776 _displayValueLabel->setTextColor(getRandomColor());
777 break;
778 case ui::ScrollView::EventType::SCROLLING_ENDED:
779 _displayValueLabel->setString("scrolling ended!");
780 _displayValueLabel->setTextColor(getRandomColor());
781 break;
782 default: break;
783 }
784 });
785
786 return true;
787 }
788
789 return false;
790}
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* UIScrollViewTestEvents::_displayValueLabel
protected

在文件 UIScrollViewTest.h169 行定义.

被这些函数引用 init().


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