cocos2d / cocos2d-objc

Cocos2d for iOS and OS X, built using Objective-C
http://www.cocos2d-objc.org
Other
4.07k stars 1.16k forks source link

CCResponderManager list stops responding to touches #862

Open fgeorg opened 10 years ago

fgeorg commented 10 years ago

Bug happens on release-3.1.1 [270f12f] but I don't think it's new. This bug is sporadic and hard to reproduce, but it seems to be a problem with cocos. We have a CCNode and we set its userInteractionEnabled to and NO then YES in quick succession while touches are happening. It then gets stuck in a state where the CCNode doesn't get touch callbacks even though userInteractionEnabled=YES. It seems to me that the problem is that the responderManager sometimes doesn't update it's responder list correctly. I fixed the problem with a temporary workaround by calling [[CCDirector sharedDirector].responderManager markAsDirty]; at the beginning of the node's touchEnded callback.

Birkemose commented 10 years ago

I would not recommend setting userInteractionEnabled in the touch callbacks. That is dubious design. Setting userInteractionEnabled will force the list of rebuild. While it is not an overly costly operation, it might be better to maintain your own enabled state, if you change it frequently.