diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index e8081a2563..27b5554097 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -581,7 +581,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() _touchListener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this); _touchListener->onTouchMoved = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchMoved, this); - EventDispatcher::getInstance()->addEventListenerWithFixedPriority(_touchListener, -100); + EventDispatcher::getInstance()->addEventListenerWithFixedPriority(_touchListener, -129); } @@ -592,14 +592,10 @@ void RemoveMenuItemWhenMove::goBack(Object *pSender) RemoveMenuItemWhenMove::~RemoveMenuItemWhenMove() { + EventDispatcher::getInstance()->removeEventListener(_touchListener); CC_SAFE_RELEASE(item); } -//void RemoveMenuItemWhenMove::registerWithTouchDispatcher(void) -//{ -// Director::getInstance()->getTouchDispatcher()->addTargetedDelegate(this, -129, false); -//} - bool RemoveMenuItemWhenMove::onTouchBegan(Touch *touch, Event *event) { return true; @@ -617,6 +613,8 @@ void RemoveMenuItemWhenMove::onTouchMoved(Touch *touch, Event *event) void MenuTestScene::runThisTest() { + MenuItemFont::setFontSize(20); + auto layer1 = new MenuLayerMainMenu(); auto layer2 = new MenuLayer2(); auto layer3 = new MenuLayer3(); diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h index a6384d0195..f023871835 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h @@ -106,7 +106,6 @@ class RemoveMenuItemWhenMove : public Layer public: RemoveMenuItemWhenMove(); ~RemoveMenuItemWhenMove(); - virtual bool onTouchBegan(Touch *touch, Event *event); virtual void onTouchMoved(Touch *touch, Event *event);