PuzzleSDK
UIRadioButtonTabTest类 参考

#include <UIRadioButtonTest.h>

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

Public 成员函数

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

详细描述

在文件 UIRadioButtonTest.h78 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRadioButtonTabTest::CREATE_FUNC ( UIRadioButtonTabTest  )

◆ init()

bool UIRadioButtonTabTest::init ( )
overridevirtual

重载 UIScene .

在文件 UIRadioButtonTest.cpp318 行定义.

319{
320 if (UIScene::init())
321 {
322 Size widgetSize = _widget->getContentSize();
323
324 static const float BUTTON_SCALE = 0.5f;
325 const float buttonWidth = 350 * BUTTON_SCALE / Director::getInstance()->getContentScaleFactor();
326
327 // Background for buttons
328 LayerColor* colorLayer = LayerColor::create(Color4B::WHITE);
329 colorLayer->setIgnoreAnchorPointForPosition(false);
330 colorLayer->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
331 colorLayer->setContentSize(Size(buttonWidth * 3, 170 / Director::getInstance()->getContentScaleFactor()));
332 colorLayer->setPosition(widgetSize / 2.0f);
333 _uiLayer->addChild(colorLayer);
334
335 // Create a radio button group
336 RadioButtonGroup* radioButtonGroup = RadioButtonGroup::create();
337 _uiLayer->addChild(radioButtonGroup);
338
339 // Create the radio buttons
340 static const int NUMBER_OF_BUTTONS = 3;
341 float startPosX = widgetSize.width / 2.0f - ((NUMBER_OF_BUTTONS - 1) / 2.0f) * buttonWidth;
342 for(int i = 0; i < NUMBER_OF_BUTTONS; ++i)
343 {
344 auto filePathNormal = StringUtils::format("cocosui/btn_exercise%02d_n.png", i + 1);
345 auto filePathSelected = StringUtils::format("cocosui/btn_exercise%02d_p.png", i + 1);
346 RadioButton* radioButton = RadioButton::create(filePathNormal, filePathSelected);
347 float posX = startPosX + buttonWidth * i;
348 radioButton->setPosition(Vec2(posX, widgetSize.height / 2.0f));
349 radioButton->setScale(BUTTON_SCALE);
350 radioButton->setZoomScale(0.05f);
351 radioButtonGroup->addRadioButton(radioButton);
352 _uiLayer->addChild(radioButton);
353 }
354 radioButtonGroup->setSelectedButton(0);
355 return true;
356 }
357 return false;
358}
static float startPosX
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() , 以及 startPosX.

+ 函数调用图:

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