how to setSwallowTouches the controlbutton?

how to setSwallowTouches the controlbutton?
0.0 0


3.0的controlbutton 如何吞噬触摸?


Hello everyone!

I have also an issue with the ControlButton. In cocos2d-x version 2.2.3 it was okay but in version 3.0b and 3.0rc0 I have the following problem. I created a new project by following the instructions in the file. Then I added a listener for onTouchBegan to the EventDispatcher with the method addEventListenerWithSceneGraphPriority() … that is in the initialization of the HelloWorldScene.cpp. So when I tap the screen (the main and the only layer) I write something to the console. Everything okay. After adding the event listener I add a ControlButton to the layer (also in the init() method) as follows:

ControlButton* button = ControlButton::create("[ START ]", "Arial", 30);
button->setPosition(Point(_screenWidth/2, _screenHeight/2));
button->addTargetWithActionForControlEvecoconts(this, cccontrol_selector(HelloWorld::onStartButtonClick), Control::EventType::TOUCH_UP_INSIDE);

The callback also prints somtething to the console. The problem is: the touch events are going through the button to the layer so both touches are recognized (both callbacks are fired everytime). I just can’t figure out what do I need to do to make the ControlButton swallow the touches. I tried with setting the touch priority, Z order, etc.

Thanks for your help!


can someone help us?:wink:


Is there anyone alive in this Forum???I have the same question!!!


I think it a bug for me i just fix it inside Control class just add where SwallowTouches


Hey guys @ha397666 @developer86 @leonbao2010 @newnon,

It’s a bug, and you can refer to this pull request ( to fix it.