3
\$\begingroup\$

How do I callback a function when label is touched in cocos2d-x?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

you can't set a callback function for CCLabelTTF or any other Label class, yet there is CCMenuItemLabel you can use.

you first need to create an instance of CCMenu class. then you need to allocate CCMenuItemLabel instance, using CCMenuItem::initWithLabel (CCNode *label, CCObject *target, SEL_MenuHandler selector). just check how helloworld sample handled it, although it's using CCMenuItemImage, but the base idea is just same in both.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .