PuzzleSDK
UILayoutTest_Layout_Relative_Location类 参考

#include <UILayoutTest.h>

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

Public 成员函数

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

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- 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
 

详细描述

在文件 UILayoutTest.h117 行定义.

构造及析构函数说明

◆ UILayoutTest_Layout_Relative_Location()

UILayoutTest_Layout_Relative_Location::UILayoutTest_Layout_Relative_Location ( )

在文件 UILayoutTest.cpp662 行定义.

663{
664}

◆ ~UILayoutTest_Layout_Relative_Location()

UILayoutTest_Layout_Relative_Location::~UILayoutTest_Layout_Relative_Location ( )

在文件 UILayoutTest.cpp666 行定义.

667{
668}

成员函数说明

◆ CREATE_FUNC()

UILayoutTest_Layout_Relative_Location::CREATE_FUNC ( UILayoutTest_Layout_Relative_Location  )

◆ init()

bool UILayoutTest_Layout_Relative_Location::init ( )
overridevirtual

重载 UIScene .

在文件 UILayoutTest.cpp670 行定义.

671{
672 if (UIScene::init())
673 {
674 Size widgetSize = _widget->getContentSize();
675
676 // Add the alert
677 Text* alert = Text::create("Layout Relative Location", "fonts/Marker Felt.ttf", 20);
678 alert->setColor(Color3B(159, 168, 176));
679 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
680 _uiLayer->addChild(alert);
681
682 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
683
684 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
685
686 // Create the layout
687 Layout* layout = Layout::create();
688 layout->setLayoutType(Layout::Type::RELATIVE);
689 layout->setContentSize(Size(280, 150));
690 Size backgroundSize = background->getContentSize();
691 layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
692 (backgroundSize.width - layout->getContentSize().width) / 2.0f,
693 (widgetSize.height - backgroundSize.height) / 2.0f +
694 (backgroundSize.height - layout->getContentSize().height) / 2.0f));
695 _uiLayer->addChild(layout);
696
697 // center
698 ImageView* imageView_Center = ImageView::create("cocosui/scrollviewbg.png");
699 layout->addChild(imageView_Center);
700
701 RelativeLayoutParameter* rp_Center = RelativeLayoutParameter::create();
702 rp_Center->setRelativeName("rp_Center");
703 rp_Center->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT);
704 imageView_Center->setLayoutParameter(rp_Center);
705
706
707 // above center
708 ImageView* imageView_AboveCenter = ImageView::create("cocosui/switch-mask.png");
709 layout->addChild(imageView_AboveCenter);
710
711 RelativeLayoutParameter* rp_AboveCenter = RelativeLayoutParameter::create();
712 rp_AboveCenter->setRelativeToWidgetName("rp_Center");
713 rp_AboveCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER);
714 imageView_AboveCenter->setLayoutParameter(rp_AboveCenter);
715
716
717 // below center
718 ImageView* imageView_BelowCenter = ImageView::create("cocosui/switch-mask.png");
719 layout->addChild(imageView_BelowCenter);
720
721 RelativeLayoutParameter* rp_BelowCenter = RelativeLayoutParameter::create();
722 rp_BelowCenter->setRelativeToWidgetName("rp_Center");
723 rp_BelowCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER);
724 imageView_BelowCenter->setLayoutParameter(rp_BelowCenter);
725
726
727 // left center
728 ImageView* imageView_LeftCenter = ImageView::create("cocosui/switch-mask.png");
729 layout->addChild(imageView_LeftCenter);
730
731 RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
732 rp_LeftCenter->setRelativeToWidgetName("rp_Center");
733 rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER);
734 imageView_LeftCenter->setLayoutParameter(rp_LeftCenter);
735
736
737
738 // right center
739 ImageView* imageView_RightCenter = ImageView::create("cocosui/switch-mask.png");
740 layout->addChild(imageView_RightCenter);
741
742 RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
743 rp_RightCenter->setRelativeToWidgetName("rp_Center");
744 rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER);
745 imageView_RightCenter->setLayoutParameter(rp_RightCenter);
746
747
748 return true;
749 }
750
751 return false;
752}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 UIScene::_uiLayer, UIScene::_widget , 以及 UIScene::init().

+ 函数调用图:

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