PuzzleSDK
Issue8194类 参考

#include <NewEventDispatcherTest.h>

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

Public 成员函数

 CREATE_FUNC (Issue8194)
 
 Issue8194 ()
 
virtual ~Issue8194 ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
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
 
virtual void onEnter () override
 

Private 属性

cocos2d::EventListenerCustom * _listener
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 NewEventDispatcherTest.h286 行定义.

构造及析构函数说明

◆ Issue8194()

Issue8194::Issue8194 ( )

在文件 NewEventDispatcherTest.cpp1590 行定义.

1591{
1592 auto origin = Director::getInstance()->getVisibleOrigin();
1593 auto size = Director::getInstance()->getVisibleSize();
1594 static bool nodesAdded = false;
1595#define tagA 100
1596#define tagB 101
1597 // dispatch custom event in another custom event, make the custom event "Issue8194" take effect immediately
1598 _listener = getEventDispatcher()->addCustomEventListener(Director::EVENT_AFTER_UPDATE, [this](cocos2d::EventCustom *event){
1599 if (nodesAdded)
1600 {
1601 // CCLOG("Fire Issue8194 Event");
1602 getEventDispatcher()->dispatchCustomEvent("Issue8194");
1603
1604 // clear test nodes and listeners
1605 getEventDispatcher()->removeCustomEventListeners("Issue8194");
1606 removeChildByTag(tagA);
1607 removeChildByTag(tagB);
1608 nodesAdded = false;
1609 }
1610 });
1611
1612 // When click this menuitem, it will add two node A and B, then send a custom event.
1613 // Because Node B's localZOrder < A's, the custom event should process by node B.
1614 auto menuItem = MenuItemFont::create("Dispatch Custom Event", [this](Ref *sender) {
1615 // add nodeA to scene
1616 auto nodeA = Node::create();
1617 addChild(nodeA, 1, tagA);
1618
1619 cocos2d::EventListenerCustom* listenerA = cocos2d::EventListenerCustom::create("Issue8194", [&](cocos2d::EventCustom *event){
1620 _subtitleLabel->setString("Bug has been fixed.");
1621 event->stopPropagation();
1622 });
1623 getEventDispatcher()->addEventListenerWithSceneGraphPriority(listenerA, nodeA);
1624
1625 // add nodeB to scene
1626 auto nodeB = Node::create();
1627 addChild(nodeB, -1, tagB);
1628
1629 cocos2d::EventListenerCustom* listenerB = cocos2d::EventListenerCustom::create("Issue8194", [&](cocos2d::EventCustom *event){
1630 _subtitleLabel->setString("Bug exist yet.");
1631 event->stopPropagation();
1632 });
1633 getEventDispatcher()->addEventListenerWithSceneGraphPriority(listenerB, nodeB);
1634
1635 nodesAdded = true;
1636 });
1637
1638 menuItem->setPosition(origin.x + size.width/2, origin.y + size.height/2);
1639 auto menu = Menu::create(menuItem, nullptr);
1640 menu->setPosition(Vec2::ZERO);
1641 addChild(menu);
1642}
#define tagA
#define tagB
cocos2d::EventListenerCustom * _listener
cocos2d::Label * _subtitleLabel
Definition: BaseTest.h:107

引用了 _listener, TestCase::_subtitleLabel, tagA , 以及 tagB.

◆ ~Issue8194()

Issue8194::~Issue8194 ( )
virtual

在文件 NewEventDispatcherTest.cpp1644 行定义.

1645{
1646 getEventDispatcher()->removeEventListener(_listener);
1647}

引用了 _listener.

成员函数说明

◆ CREATE_FUNC()

Issue8194::CREATE_FUNC ( Issue8194  )

◆ subtitle()

std::string Issue8194::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 NewEventDispatcherTest.cpp1654 行定义.

1655{
1656 return "After click button, should show 'Bug has been fixed.'";
1657}

◆ title()

std::string Issue8194::title ( ) const
overridevirtual

重载 EventDispatcherTestDemo .

在文件 NewEventDispatcherTest.cpp1649 行定义.

1650{
1651 return "Issue 8194";
1652}

类成员变量说明

◆ _listener

cocos2d::EventListenerCustom* Issue8194::_listener
private

在文件 NewEventDispatcherTest.h297 行定义.

被这些函数引用 Issue8194() , 以及 ~Issue8194().


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