cocos2d-iphoneccmenuitem

Have CCMenuItem fire its block on touchdown


CCMenuItem default fires its block on touchup. I'd like to change this to touchdown. Anyway to perform this without modifying CCMenu class (which would break other parts). Can this be done in a category?

Wonder why the events are not implemented same way as UIKit (free event selection).


Solution

  • You can subclass CCMenuItem and make this behaviour possible by overriding selected, unselected and activate, depending on your needs.

    You can then use your new class in CCMenu so that you can lay it out automatically and the rest of your app will continue to function.