PuzzleSDK
UIButtonTestRemoveSelf类 参考

#include <UIButtonTest.h>

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

Public 成员函数

 CREATE_FUNC (UIButtonTestRemoveSelf)
 
 UIButtonTestRemoveSelf ()
 
 ~UIButtonTestRemoveSelf ()
 
virtual bool init () override
 
void touchEvent (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType 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.h110 行定义.

构造及析构函数说明

◆ UIButtonTestRemoveSelf()

UIButtonTestRemoveSelf::UIButtonTestRemoveSelf ( )

在文件 UIButtonTest.cpp536 行定义.

537: _displayValueLabel(nullptr)
538{
539
540}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:122

◆ ~UIButtonTestRemoveSelf()

UIButtonTestRemoveSelf::~UIButtonTestRemoveSelf ( )

在文件 UIButtonTest.cpp542 行定义.

543{
544}

成员函数说明

◆ CREATE_FUNC()

UIButtonTestRemoveSelf::CREATE_FUNC ( UIButtonTestRemoveSelf  )

◆ init()

bool UIButtonTestRemoveSelf::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp546 行定义.

547{
548 if (UIScene::init())
549 {
550 Size widgetSize = _widget->getContentSize();
551
552 // Add a label in which the button events will be displayed
553 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
554 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
555 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
556 _uiLayer->addChild(_displayValueLabel);
557
558 // Add the alert
559 Text* alert = Text::create("Remove Self in the Button's Callback shouldn't cause crash!","fonts/Marker Felt.ttf",10);
560 alert->setColor(Color3B(159, 168, 176));
561
562 alert->setPosition(Vec2(widgetSize.width / 2.0f,
563 widgetSize.height / 2.0f - alert->getContentSize().height * 2.75f));
564
565 _uiLayer->addChild(alert);
566
567 Layout *layout = Layout::create();
568 layout->setContentSize(widgetSize * 0.6f);
569 layout->setBackGroundColor(Color3B::GREEN);
570 layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
571 layout->setBackGroundColorOpacity(100);
572 layout->setPosition(Size(widgetSize.width/2, widgetSize.height/2));
573 layout->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
574 layout->setTag(12);
575 _uiLayer->addChild(layout);
576
577 // Create the button
578 Button* button = Button::create("cocosui/animationbuttonnormal.png",
579 "cocosui/animationbuttonpressed.png");
580 button->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
581 // button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
582 button->addTouchEventListener(CC_CALLBACK_2(UIButtonTestRemoveSelf::touchEvent, this));
583 layout->addChild(button);
584
585
586
587 return true;
588 }
589 return false;
590}
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType 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() , 以及 touchEvent().

+ 函数调用图:

◆ touchEvent()

void UIButtonTestRemoveSelf::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIButtonTest.cpp592 行定义.

593{
594 switch (type)
595 {
596 case Widget::TouchEventType::BEGAN:
597 _displayValueLabel->setString(StringUtils::format("Touch Down"));
598 break;
599
600 case Widget::TouchEventType::MOVED:
601 _displayValueLabel->setString(StringUtils::format("Touch Move"));
602 break;
603
604 case Widget::TouchEventType::ENDED:
605 {
606 _displayValueLabel->setString(StringUtils::format("Touch Up"));
607 auto layout = _uiLayer->getChildByTag(12);
608 layout->removeFromParentAndCleanup(true);
609 }
610 break;
611
612 case Widget::TouchEventType::CANCELED:
613 _displayValueLabel->setString(StringUtils::format("Touch Cancelled"));
614 break;
615
616 default:
617 break;
618 }
619}

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

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTestRemoveSelf::_displayValueLabel
protected

在文件 UIButtonTest.h122 行定义.

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


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