PuzzleSDK
UIButtonTestZoomScale类 参考

#include <UIButtonTest.h>

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

Public 成员函数

 CREATE_FUNC (UIButtonTestZoomScale)
 
 UIButtonTestZoomScale ()
 
 ~UIButtonTestZoomScale ()
 
virtual bool init () override
 
void sliderEvent (cocos2d::Ref *sender, cocos2d::ui::Slider::EventType type)
 
- 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::Text * _displayValueLabel
 
- 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
 

详细描述

在文件 UIButtonTest.h140 行定义.

构造及析构函数说明

◆ UIButtonTestZoomScale()

UIButtonTestZoomScale::UIButtonTestZoomScale ( )

在文件 UIButtonTest.cpp694 行定义.

695: _displayValueLabel(nullptr)
696{
697
698}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:152

◆ ~UIButtonTestZoomScale()

UIButtonTestZoomScale::~UIButtonTestZoomScale ( )

在文件 UIButtonTest.cpp700 行定义.

701{
702}

成员函数说明

◆ CREATE_FUNC()

UIButtonTestZoomScale::CREATE_FUNC ( UIButtonTestZoomScale  )

◆ init()

bool UIButtonTestZoomScale::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp704 行定义.

705{
706 if (UIScene::init())
707 {
708 Size widgetSize = _widget->getContentSize();
709
710 // Add a label in which the button events will be displayed
711 _displayValueLabel = Text::create("Zoom Scale: -0.5", "fonts/Marker Felt.ttf",32);
712 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
713 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 20));
714 _uiLayer->addChild(_displayValueLabel);
715
716
717 // Create the button
718 Button* button = Button::create("cocosui/animationbuttonnormal.png",
719 "cocosui/animationbuttonpressed.png");
720 button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 20));
721 button->setPressedActionEnabled(true);
722 button->addClickEventListener([=](Ref* sender){
723 CCLOG("Button clicked, position = (%f, %f)", button->getPosition().x,
724 button->getPosition().y);
725
726 });
727 button->setName("button");
728 _uiLayer->addChild(button);
729 button->setZoomScale(-0.5);
730
731 Slider* slider = Slider::create();
732 slider->loadBarTexture("cocosui/sliderTrack.png");
733 slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
734 slider->loadProgressBarTexture("cocosui/sliderProgress.png");
735 slider->setPosition(Vec2(widgetSize.width / 2.0f , widgetSize.height / 2.0f - 20));
736 slider->addEventListener(CC_CALLBACK_2(UIButtonTestZoomScale::sliderEvent, this));
737 slider->setPercent(button->getZoomScale()*100);
738 _uiLayer->addChild(slider);
739 return true;
740 }
741 return false;
742}
void sliderEvent(cocos2d::Ref *sender, cocos2d::ui::Slider::EventType type)
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 _displayValueLabel, UIScene::_uiLayer, UIScene::_widget, UIScene::init() , 以及 sliderEvent().

+ 函数调用图:

◆ sliderEvent()

void UIButtonTestZoomScale::sliderEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Slider::EventType  type 
)

在文件 UIButtonTest.cpp744 行定义.

745{
746 if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
747 {
748 Slider* slider = dynamic_cast<Slider*>(pSender);
749 int percent = slider->getPercent();
750 Button* btn = (Button*)_uiLayer->getChildByName("button");
751 float zoomScale = percent * 0.01;
752 btn->setZoomScale(zoomScale);
753 _displayValueLabel->setString(StringUtils::format("Zoom Scale: %f", zoomScale));
754 }
755}

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

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTestZoomScale::_displayValueLabel
protected

在文件 UIButtonTest.h152 行定义.

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


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