Hi.
In v.2.x I could enable/disable touch detection by using CCLayer::setTouchEnabled method.
In v.3 I can’t do that.
I found protected method EventListener::setPaused and made it public. But it appears that Cocos2d-x can change the ‘paused’-flag by itself in EventDispatcher::pauseEventListenersForTarget/resumeEventListenersForTarget.
So I have a proposition: make a public EventListener::setEnabled method which will enable/disable an EventListener. EventListener should work if (!_paused && _enabled) is true.
Hi @dotsquid,
Currently, EventListener::setPaused
is protected method. It seems that we don’t need a setEnabled
, just make setPaused
public.
I think the behavior between setPaused
and setEnabled
is the same.
No, they aren’t the same.
First of all, I’ve just realized that I’ve got an error in my previous message: it should be (!_paused && _enabled).
There are some places where Cocos2d-x overwrites “paused” state by itself. For instance, when the Node is paused/resumed all attached listeners are paused/resumed as well.
That makes sense.
Yep, I think EventListener::setEnabled
is needed.
@dotsquid
I have sent a PR here, https://github.com/cocos2d/cocos2d-x/pull/6130
Could you please test it ? Thanks.
Seems to be working. Thanks.