Handle permanent press on CCMenuItem

Hello, I’m new to cocos2d and I’m trying to handle callbacks of “pressed” event.

That is, when I’ll press on a button, my callback will be invoked until I won’t release button.
I’m trying to implement subclass of CCMenuItemImage and process selected() and unselected() functions,
but this is not what I want. This functions called when I only select or unselect button once, not permanently.
How can I achieve this behavior?

Thank you!

Can anyone help me?

in selected() call scheduleUpdate(), in unselected() call unscheduleUpdate(). Override update(float dt) and do there what you want to be done.

Igor Zavorotkin wrote:

in selected() call scheduleUpdate(), in unselected() call unscheduleUpdate(). Override update(float dt) and do there what you want to be done.

Thanks! It works.

Instead of overriding update(float dt), I would rather schedule another method using the schedule( schedule_selector( ) ) function. I think that’s safer, I’m not sure.