PuzzleSDK
UILayoutTest_Layout_Relative_Align_Parent类 参考

#include <UILayoutTest.h>

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

Public 成员函数

 UILayoutTest_Layout_Relative_Align_Parent ()
 
 ~UILayoutTest_Layout_Relative_Align_Parent ()
 
virtual bool init () override
 
 CREATE_FUNC (UILayoutTest_Layout_Relative_Align_Parent)
 
- 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.h107 行定义.

构造及析构函数说明

◆ UILayoutTest_Layout_Relative_Align_Parent()

UILayoutTest_Layout_Relative_Align_Parent::UILayoutTest_Layout_Relative_Align_Parent ( )

在文件 UILayoutTest.cpp527 行定义.

528{
529}

◆ ~UILayoutTest_Layout_Relative_Align_Parent()

UILayoutTest_Layout_Relative_Align_Parent::~UILayoutTest_Layout_Relative_Align_Parent ( )

在文件 UILayoutTest.cpp531 行定义.

532{
533}

成员函数说明

◆ CREATE_FUNC()

UILayoutTest_Layout_Relative_Align_Parent::CREATE_FUNC ( UILayoutTest_Layout_Relative_Align_Parent  )

◆ init()

bool UILayoutTest_Layout_Relative_Align_Parent::init ( )
overridevirtual

重载 UIScene .

在文件 UILayoutTest.cpp535 行定义.

536{
537 if (UIScene::init())
538 {
539 Size widgetSize = _widget->getContentSize();
540
541 // Add the alert
542 Text* alert = Text::create("Layout Relative Align Parent", "fonts/Marker Felt.ttf", 20);
543 alert->setColor(Color3B(159, 168, 176));
544 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
545 _uiLayer->addChild(alert);
546
547 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
548
549 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
550
551 // Create the layout
552 Layout* layout = Layout::create();
553 layout->setLayoutType(Layout::Type::RELATIVE);
554 layout->setContentSize(Size(280, 150));
555 layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
556 layout->setBackGroundColor(Color3B::GREEN);
557 Size backgroundSize = background->getContentSize();
558 layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
559 (backgroundSize.width - layout->getContentSize().width) / 2.0f,
560 (widgetSize.height - backgroundSize.height) / 2.0f +
561 (backgroundSize.height - layout->getContentSize().height) / 2.0f));
562 _uiLayer->addChild(layout);
563
564 // top left
565 Button* button_TopLeft = Button::create("cocosui/animationbuttonnormal.png",
566 "cocosui/animationbuttonpressed.png");
567 layout->addChild(button_TopLeft);
568
569 RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();
570 rp_TopLeft->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT);
571 button_TopLeft->setLayoutParameter(rp_TopLeft);
572
573
574 // top center horizontal
575 Button* button_TopCenter = Button::create("cocosui/animationbuttonnormal.png",
576 "cocosui/animationbuttonpressed.png");
577 layout->addChild(button_TopCenter);
578
579 RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();
580 rp_TopCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL);
581 button_TopCenter->setLayoutParameter(rp_TopCenter);
582
583
584 // top right
585 Button* button_TopRight = Button::create("cocosui/animationbuttonnormal.png",
586 "cocosui/animationbuttonpressed.png");
587 layout->addChild(button_TopRight);
588
589 RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();
590 rp_TopRight->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT);
591 button_TopRight->setLayoutParameter(rp_TopRight);
592
593
594 // left center
595 Button* button_LeftCenter = Button::create("cocosui/animationbuttonnormal.png",
596 "cocosui/animationbuttonpressed.png");
597 layout->addChild(button_LeftCenter);
598
599 RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
600 rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL);
601 button_LeftCenter->setLayoutParameter(rp_LeftCenter);
602
603
604 // center
605 Button* buttonCenter = Button::create("cocosui/animationbuttonnormal.png",
606 "cocosui/animationbuttonpressed.png");
607 layout->addChild(buttonCenter);
608
609 RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();
610 rpCenter->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT);
611 buttonCenter->setLayoutParameter(rpCenter);
612
613
614 // right center
615 Button* button_RightCenter = Button::create("cocosui/animationbuttonnormal.png",
616 "cocosui/animationbuttonpressed.png");
617 layout->addChild(button_RightCenter);
618
619 RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
620 rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL);
621 button_RightCenter->setLayoutParameter(rp_RightCenter);
622
623
624 // left bottom
625 Button* button_LeftBottom = Button::create("cocosui/animationbuttonnormal.png",
626 "cocosui/animationbuttonpressed.png");
627 layout->addChild(button_LeftBottom);
628
629 RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();
630 rp_LeftBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM);
631 button_LeftBottom->setLayoutParameter(rp_LeftBottom);
632
633
634 // bottom center
635 Button* button_BottomCenter = Button::create("cocosui/animationbuttonnormal.png",
636 "cocosui/animationbuttonpressed.png");
637 layout->addChild(button_BottomCenter);
638
639 RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();
640 rp_BottomCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL);
641 button_BottomCenter->setLayoutParameter(rp_BottomCenter);
642
643
644 // right bottom
645 Button* button_RightBottom = Button::create("cocosui/animationbuttonnormal.png",
646 "cocosui/animationbuttonpressed.png");
647 layout->addChild(button_RightBottom);
648
649 RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();
650 rp_RightBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM);
651 button_RightBottom->setLayoutParameter(rp_RightBottom);
652
653
654 return true;
655 }
656
657 return false;
658}
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().

+ 函数调用图:

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