PuzzleSDK
UITextAtlasTest类 参考

#include <UITextAtlasTest.h>

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

Public 成员函数

 CREATE_FUNC (UITextAtlasTest)
 
virtual bool init () override
 
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::TextAtlas * _textAtlas
 
- 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
 

详细描述

在文件 UITextAtlasTest.h34 行定义.

成员函数说明

◆ CREATE_FUNC()

UITextAtlasTest::CREATE_FUNC ( UITextAtlasTest  )

◆ init()

bool UITextAtlasTest::init ( )
overridevirtual

重载 UIScene .

在文件 UITextAtlasTest.cpp37 行定义.

38{
39 if (UIScene::init())
40 {
41 Size widgetSize = _widget->getContentSize();
42
43 // Add the alert
44 Text* alert = Text::create("TextAtlas","fonts/Marker Felt.ttf",30);
45 alert->setColor(Color3B(159, 168, 176));
46 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
47 _uiLayer->addChild(alert);
48
49 // Create the text atlas
50 TextAtlas* textAtlas = nullptr;
51 if (Director::getInstance()->getWinSizeInPixels().height > 320.f)
52 {
53 textAtlas = TextAtlas::create("1234567890", "cocosui/labelatlas.png", 34, 44, "0");
54 }
55 else
56 {
57 textAtlas = TextAtlas::create("1234567890", "cocosui/labelatlas.png", 17, 22, "0");
58 }
59 textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f));
60 _uiLayer->addChild(textAtlas);
61 _textAtlas = textAtlas;
62
63 TTFConfig ttfConfig("fonts/arial.ttf", 15);
64 auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
65 auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printWidgetResources, this));
66 item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
67 auto pMenu1 = Menu::create(item1, nullptr);
68 pMenu1->setPosition(Vec2(0, 0));
69 this->addChild(pMenu1, 10);
70 return true;
71 }
72 return false;
73}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45
void printWidgetResources(cocos2d::Ref *sender)
cocos2d::ui::TextAtlas * _textAtlas
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45

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

+ 函数调用图:

◆ printWidgetResources()

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

在文件 UITextAtlasTest.cpp74 行定义.

75{
76 cocos2d::ResourceData textureFile = _textAtlas->getRenderFile();
77 CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
78}

引用了 _textAtlas.

被这些函数引用 init().

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

类成员变量说明

◆ _textAtlas

cocos2d::ui::TextAtlas* UITextAtlasTest::_textAtlas
protected

在文件 UITextAtlasTest.h42 行定义.

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


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