PuzzleSDK
UILoadingBarReloadTexture类 参考

#include <UILoadingBarTest.h>

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

Public 成员函数

 CREATE_FUNC (UILoadingBarReloadTexture)
 
 UILoadingBarReloadTexture ()
 
 ~UILoadingBarReloadTexture ()
 
void update (float dt) override
 
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
 

Protected 属性

int _count
 
- 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
 

详细描述

在文件 UILoadingBarTest.h104 行定义.

构造及析构函数说明

◆ UILoadingBarReloadTexture()

UILoadingBarReloadTexture::UILoadingBarReloadTexture ( )

在文件 UILoadingBarTest.cpp366 行定义.

367: _count(0)
368{
369
370}

◆ ~UILoadingBarReloadTexture()

UILoadingBarReloadTexture::~UILoadingBarReloadTexture ( )

在文件 UILoadingBarTest.cpp372 行定义.

373{
374
375}

成员函数说明

◆ CREATE_FUNC()

UILoadingBarReloadTexture::CREATE_FUNC ( UILoadingBarReloadTexture  )

◆ init()

bool UILoadingBarReloadTexture::init ( )
overridevirtual

重载 UIScene .

在文件 UILoadingBarTest.cpp377 行定义.

378{
379 if (UIScene::init())
380 {
381 Size widgetSize = _widget->getContentSize();
382
383 // Add the alert
384 Text *alert = Text::create("Click button to Toggle Scale9 and switch Texture.", "fonts/Marker Felt.ttf", 20);
385 alert->setColor(Color3B(159, 168, 176));
386 alert->setPosition(Vec2(widgetSize.width / 2.0f,
387 widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f));
388 _uiLayer->addChild(alert);
389
390 LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
391 loadingBar->setTag(0);
392 loadingBar->ignoreContentAdaptWithSize(false);
393// loadingBar->setScale9Enabled(true);
394 loadingBar->setCapInsets(Rect(0, 0, 0, 0));
395 loadingBar->setContentSize(Size(300, 13));
396 loadingBar->setName("texture0");
397 loadingBar->setDirection(LoadingBar::Direction::RIGHT);
398 loadingBar->setPercent(70);
399 loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
400 widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
401
402 _uiLayer->addChild(loadingBar);
403
404 auto buttonScale9 = Button::create("cocosui/animationbuttonnormal.png",
405 "cocosui/animationbuttonpressed.png");
406 buttonScale9->setTitleText("ToggleScale9");
407 buttonScale9->addClickEventListener([=](Ref*){
408 loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled());
409 });
410 buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50));
411 _uiLayer->addChild(buttonScale9);
412
413 auto buttonChangeTexture = Button::create("cocosui/animationbuttonnormal.png",
414 "cocosui/animationbuttonpressed.png");
415 buttonChangeTexture->setTitleText("ChangeTexture");
416 buttonChangeTexture->addClickEventListener([=](Ref*){
417 auto name = loadingBar->getName();
418 if (name == "texture0")
419 {
420 loadingBar->loadTexture("cocosui/slider_bar_active_9patch2.png");
421 loadingBar->setName("texture1");
422 }
423 else
424 {
425 loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
426 loadingBar->setName("texture0");
427 }
428 });
429 buttonChangeTexture->setPosition(loadingBar->getPosition() + Vec2(50,50));
430 _uiLayer->addChild(buttonChangeTexture);
431
432 this->scheduleUpdate();
433 return true;
434 }
435 return false;
436}
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().

+ 函数调用图:

◆ update()

void UILoadingBarReloadTexture::update ( float  dt)
override

在文件 UILoadingBarTest.cpp438 行定义.

439{
440 _count++;
441 if (_count > 100)
442 {
443 _count = 0;
444 }
445 LoadingBar* loadingBar = static_cast<LoadingBar*>(_uiLayer->getChildByTag(0));
446 loadingBar->setPercent(_count);
447}

引用了 _count , 以及 UIScene::_uiLayer.

类成员变量说明

◆ _count

int UILoadingBarReloadTexture::_count
protected

在文件 UILoadingBarTest.h115 行定义.

被这些函数引用 update().


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