PuzzleSDK
UILayoutTest_BackGroundImage类 参考

#include <UILayoutTest.h>

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

Public 成员函数

 UILayoutTest_BackGroundImage ()
 
 ~UILayoutTest_BackGroundImage ()
 
virtual bool init () override
 
 CREATE_FUNC (UILayoutTest_BackGroundImage)
 
void printWidgetResources (cocos2d::Ref *sender)
 
- 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::Layout * _layout
 
- 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
 

详细描述

在文件 UILayoutTest.h63 行定义.

构造及析构函数说明

◆ UILayoutTest_BackGroundImage()

UILayoutTest_BackGroundImage::UILayoutTest_BackGroundImage ( )

在文件 UILayoutTest.cpp239 行定义.

240{
241}

◆ ~UILayoutTest_BackGroundImage()

UILayoutTest_BackGroundImage::~UILayoutTest_BackGroundImage ( )

在文件 UILayoutTest.cpp243 行定义.

244{
245}

成员函数说明

◆ CREATE_FUNC()

UILayoutTest_BackGroundImage::CREATE_FUNC ( UILayoutTest_BackGroundImage  )

◆ init()

bool UILayoutTest_BackGroundImage::init ( )
overridevirtual

重载 UIScene .

在文件 UILayoutTest.cpp247 行定义.

248{
249 if (UIScene::init())
250 {
251 Size widgetSize = _widget->getContentSize();
252
253 // Add the alert
254 Text* alert = Text::create("Layout background image", "fonts/Marker Felt.ttf", 20);
255 alert->setColor(Color3B(159, 168, 176));
256 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5f));
257 _uiLayer->addChild(alert);
258
259 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
260
261 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
262
263 // Create the layout with background image
264 Layout* layout = Layout::create();
265 layout->setClippingEnabled(true);
266 layout->setBackGroundImage("cocosui/Hello.png");
267 layout->setContentSize(Size(280, 150));
268 Size backgroundSize = background->getContentSize();
269 layout->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
270 (backgroundSize.width - layout->getContentSize().width) / 2.0f,
271 (widgetSize.height - backgroundSize.height) / 2.0f +
272 (backgroundSize.height - layout->getContentSize().height) / 2.0f));
273 _uiLayer->addChild(layout);
274
275 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
276 button->setPosition(Vec2(button->getContentSize().width / 2.0f,
277 layout->getContentSize().height - button->getContentSize().height / 2.0f));
278 layout->addChild(button);
279
280 Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
281 titleButton->setTitleText("Title Button");
282 titleButton->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
283 layout->addChild(titleButton);
284
285 Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
286 button_scale9->setScale9Enabled(true);
287 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
288 button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width / 2.0f,
289 button_scale9->getContentSize().height / 2.0f));
290
291 layout->addChild(button_scale9);
292
293 _layout = layout;
294
295 TTFConfig ttfConfig("fonts/arial.ttf", 15);
296 auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
297 auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printWidgetResources, this));
298 item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
299 auto pMenu1 = Menu::create(item1, nullptr);
300 pMenu1->setPosition(Vec2(0, 0));
301 this->addChild(pMenu1, 10);
302
303 return true;
304 }
305 return false;
306}
cocos2d::ui::Layout * _layout
Definition: UILayoutTest.h:74
void printWidgetResources(cocos2d::Ref *sender)
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45

引用了 _layout, UIScene::_uiLayer, UIScene::_widget, VisibleRect::bottom(), UIScene::init(), VisibleRect::left() , 以及 printWidgetResources().

+ 函数调用图:

◆ printWidgetResources()

void UILayoutTest_BackGroundImage::printWidgetResources ( cocos2d::Ref *  sender)

在文件 UILayoutTest.cpp308 行定义.

309{
310 cocos2d::ResourceData textureFile = _layout->getRenderFile();
311 CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
312}

引用了 _layout.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _layout

cocos2d::ui::Layout* UILayoutTest_BackGroundImage::_layout
protected

在文件 UILayoutTest.h74 行定义.

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


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