Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Thanks HelloWorld sample tip really helped ! :) –  2600th Mar 19 '12 at 8:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.