I'm making a menu, and I want one of the buttons to respond when user touch it down, so I made a subclass of CCMenu in order to add cctouchbegan method And manage it there. The problem is that I can make it to respond both things (menuItem & cctouch), is this normal? is there a way to force it to do both things? Thank you in advance, let me know if you need me to put some of the code here
CCMenuItem doesn't respond subclassing and adding cctouch methods to CCMenu
513 views Asked by Oscar At
2
You should look at
CCMenu.m
-- it already implementsccTouchBegan
and sets a selected flag onCCMenuItem
s. Your approach is probably not working because you're stealing the messages from your parent class.Your subclass should call
[super ccTouchBegan...]
first, then check the selected state of theCCMenuItem
s to determine which button to change visually.EDIT: Or, even easier! -- Subclass the appropriate
CCMenuItem
subclass (e.g.CCMenuItemSprite
) and overload theselected
method from it's default to include your visual alterations: