Gist Link: https://gist.github.com/haxpor/6282289
I have added holding touch functionality to CCMenuItem in which it relates to CCMenu to hold them in the scene.
The benefit is that we can have time passed since the previous holding touch returned, and also be able to check whether user is currently holding and touching on a button or not.
CCMenu will hold multiple of CCMenuItem (which can be CCMenuItemImage, CCMenuItemLabel, etc) thus CCMenu and CCMenuItem will work together to set the state of holding touch and keep track of time properly. CCMenuItem will schedule an update() function only necessary whenever user wants to enable holding-touch ability (even on the fly), this results in not extensive CPU usage.
The sourcecode is based on cocos2d-x v.2.0.3. You can compare the diff by yourself but the code is minimally changed, just look mostly at the first half of source code. I don’t push back to main branch as I don’t have a clean working repo working along with my own project.
PS. The code of CCMenu was also modified to activate when we want it to be in pressing mode (act immediately upon a touch).