PuzzleSDK
UILayoutTest类 参考

#include <UILayoutTest.h>

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

Public 成员函数

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

构造及析构函数说明

◆ UILayoutTest()

UILayoutTest::UILayoutTest ( )

在文件 UILayoutTest.cpp49 行定义.

50{
51}

◆ ~UILayoutTest()

UILayoutTest::~UILayoutTest ( )

在文件 UILayoutTest.cpp53 行定义.

54{
55}

成员函数说明

◆ CREATE_FUNC()

UILayoutTest::CREATE_FUNC ( UILayoutTest  )

◆ init()

bool UILayoutTest::init ( )
overridevirtual

重载 UIScene .

在文件 UILayoutTest.cpp57 行定义.

58{
59 if (UIScene::init())
60 {
61 Size widgetSize = _widget->getContentSize();
62
63 // Add the alert
64 Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );
65 alert->setColor(Color3B(159, 168, 176));
66 alert->setPosition(Vec2(widgetSize.width / 2.0f,
67 widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
68
69 _uiLayer->addChild(alert);
70
71 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)) ;
72
73 Layout* background = static_cast<Layout*>(root->getChildByName("background_Panel"));
74
75 // Create the layout
76 Layout* layout = Layout::create();
77 layout->setContentSize(Size(280, 150));
78 Size backgroundSize = background->getContentSize();
79 layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
80 (backgroundSize.width - layout->getContentSize().width) / 2.0f,
81 (widgetSize.height - backgroundSize.height) / 2.0f +
82 (backgroundSize.height - layout->getContentSize().height) / 2.0f));
83 _uiLayer->addChild(layout);
84
85 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
86 button->setPosition(Vec2(button->getContentSize().width / 2.0f,
87 layout->getContentSize().height - button->getContentSize().height / 2.0f));
88 layout->addChild(button);
89
90 Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
91 titleButton->setTitleText("Title Button");
92 titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
93 layout->addChild(titleButton);
94
95 Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
96 button_scale9->setScale9Enabled(true);
97 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
98 button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
99 button_scale9->getContentSize().height / 2.0f));
100
101 layout->addChild(button_scale9);
102
103 return true;
104 }
105
106 return false;
107}
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().

+ 函数调用图:

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