PuzzleSDK
RemoveMenuItemWhenMove类 参考

#include <MenuTest.h>

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

Public 成员函数

 RemoveMenuItemWhenMove ()
 
 ~RemoveMenuItemWhenMove ()
 
bool onTouchBegan (cocos2d::Touch *touch, cocos2d::Event *event)
 
void onTouchMoved (cocos2d::Touch *touch, cocos2d::Event *event)
 
void goBack (cocos2d::Ref *pSender)
 

Private 属性

cocos2d::MenuItemFont * item
 
cocos2d::EventListenerTouchOneByOne * _touchListener
 

详细描述

在文件 MenuTest.h122 行定义.

构造及析构函数说明

◆ RemoveMenuItemWhenMove()

RemoveMenuItemWhenMove::RemoveMenuItemWhenMove ( )

在文件 MenuTest.cpp515 行定义.

516{
517 auto s = Director::getInstance()->getWinSize();
518
519 auto label = Label::createWithTTF("click item and move, should not crash", "fonts/arial.ttf", 20);
520 label->setPosition(Vec2(s.width/2, s.height - 30));
521 addChild(label);
522
523 item = MenuItemFont::create("item 1");
524 item->retain();
525
526 auto back = MenuItemFont::create("go back", CC_CALLBACK_1(RemoveMenuItemWhenMove::goBack, this));
527
528 auto menu = Menu::create(item, back, nullptr);
529 addChild(menu);
530 menu->alignItemsVertically();
531
532 menu->setPosition(Vec2(s.width/2, s.height/2));
533
534 // Register Touch Event
535 _touchListener = EventListenerTouchOneByOne::create();
536 _touchListener->setSwallowTouches(false);
537
538 _touchListener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this);
539 _touchListener->onTouchMoved = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchMoved, this);
540
541 _eventDispatcher->addEventListenerWithFixedPriority(_touchListener, -129);
542
543}
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
Definition: MenuTest.cpp:556
void goBack(cocos2d::Ref *pSender)
Definition: MenuTest.cpp:545
void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)
Definition: MenuTest.cpp:561
cocos2d::MenuItemFont * item
Definition: MenuTest.h:133
cocos2d::EventListenerTouchOneByOne * _touchListener
Definition: MenuTest.h:134

引用了 _touchListener, goBack(), item, onTouchBegan() , 以及 onTouchMoved().

+ 函数调用图:

◆ ~RemoveMenuItemWhenMove()

RemoveMenuItemWhenMove::~RemoveMenuItemWhenMove ( )

在文件 MenuTest.cpp550 行定义.

551{
552 _eventDispatcher->removeEventListener(_touchListener);
553 CC_SAFE_RELEASE(item);
554}

引用了 _touchListener , 以及 item.

成员函数说明

◆ goBack()

void RemoveMenuItemWhenMove::goBack ( cocos2d::Ref *  pSender)

在文件 MenuTest.cpp545 行定义.

546{
547 static_cast<LayerMultiplex*>(_parent)->switchTo(0, false);
548}

被这些函数引用 RemoveMenuItemWhenMove().

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

◆ onTouchBegan()

bool RemoveMenuItemWhenMove::onTouchBegan ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 MenuTest.cpp556 行定义.

557{
558 return true;
559}

被这些函数引用 RemoveMenuItemWhenMove().

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

◆ onTouchMoved()

void RemoveMenuItemWhenMove::onTouchMoved ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 MenuTest.cpp561 行定义.

562{
563 if (item)
564 {
565 item->removeFromParentAndCleanup(true);
566 item->release();
567 item = nullptr;
568 }
569}

引用了 item.

被这些函数引用 RemoveMenuItemWhenMove().

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

类成员变量说明

◆ _touchListener

cocos2d::EventListenerTouchOneByOne* RemoveMenuItemWhenMove::_touchListener
private

在文件 MenuTest.h134 行定义.

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

◆ item

cocos2d::MenuItemFont* RemoveMenuItemWhenMove::item
private

在文件 MenuTest.h133 行定义.

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


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