PuzzleSDK
UIButtonTest_PressedAction类 参考

#include <UIButtonTest.h>

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

Public 成员函数

 CREATE_FUNC (UIButtonTest_PressedAction)
 
 UIButtonTest_PressedAction ()
 
 ~UIButtonTest_PressedAction ()
 
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.h80 行定义.

构造及析构函数说明

◆ UIButtonTest_PressedAction()

UIButtonTest_PressedAction::UIButtonTest_PressedAction ( )

在文件 UIButtonTest.cpp349 行定义.

350: _displayValueLabel(nullptr)
351{
352}
cocos2d::ui::Text * _displayValueLabel
Definition: UIButtonTest.h:92

◆ ~UIButtonTest_PressedAction()

UIButtonTest_PressedAction::~UIButtonTest_PressedAction ( )

在文件 UIButtonTest.cpp354 行定义.

355{
356}

成员函数说明

◆ CREATE_FUNC()

UIButtonTest_PressedAction::CREATE_FUNC ( UIButtonTest_PressedAction  )

◆ init()

bool UIButtonTest_PressedAction::init ( )
overridevirtual

重载 UIScene .

在文件 UIButtonTest.cpp358 行定义.

359{
360 if (UIScene::init())
361 {
362 Size widgetSize = _widget->getContentSize();
363
364 // Add a label in which the button events will be displayed
365 _displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
366 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
367 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
368 _uiLayer->addChild(_displayValueLabel);
369
370 // Add the alert
371 Text* alert = Text::create("Button Pressed Action", "fonts/Marker Felt.ttf", 30);
372 alert->setColor(Color3B(159, 168, 176));
373
374 alert->setPosition(Vec2(widgetSize.width / 2.0f,
375 widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
376
377 _uiLayer->addChild(alert);
378
379 // Create the button
380 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
381 button->setPressedActionEnabled(true);
382 button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
383 button->setColor(Color3B::GREEN);
384 button->setOpacity(30);
385 button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_PressedAction::touchEvent, this));
386 button->setName("button");
387 _uiLayer->addChild(button);
388
389 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
390 button2->setPosition(button->getPosition() + Vec2(100.0f,0.0f));
391 button2->setName("button2");
392 _uiLayer->addChild(button2);
393
394 return true;
395 }
396 return false;
397}
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 UIButtonTest_PressedAction::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIButtonTest.cpp399 行定义.

400{
401 switch (type)
402 {
403 case Widget::TouchEventType::BEGAN:
404 _displayValueLabel->setString(StringUtils::format("Touch Down"));
405 break;
406
407 case Widget::TouchEventType::MOVED:
408 _displayValueLabel->setString(StringUtils::format("Touch Move"));
409 break;
410
411 case Widget::TouchEventType::ENDED:
412 {
413 _displayValueLabel->setString(StringUtils::format("Touch Up"));
414 Button* btn = (Button*)_uiLayer->getChildByName("button");
415 btn->loadTextureNormal("cocosui/animationbuttonnormal.png");
416
417 Button* btn2 = (Button*)_uiLayer->getChildByName("button2");
418 btn2->setAnchorPoint(Vec2(0,0.5));
419 }
420 break;
421
422 case Widget::TouchEventType::CANCELED:
423 _displayValueLabel->setString(StringUtils::format("Touch Cancelled"));
424 break;
425
426 default:
427 break;
428 }
429}

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

被这些函数引用 init().

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

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIButtonTest_PressedAction::_displayValueLabel
protected

在文件 UIButtonTest.h92 行定义.

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


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