Cocos2dx V2.2.5
Okay I have a sprite let’s say a red button. When I click the red button I want the red button to do something.
How do I do that? can you give me a code snippet?? I dont want to use the CCMenu thingy, .can I do that? or is CCMenu the only way?
You can use onTouch event on an parent Node like this:
bool Board::onTouchBegan(Touch* touch, Event* event){
Point touchLocation = touch->getLocation();
Rect rect = spriteButton->getBoundingBox();
if (rect.containsPoint(touchLocation))
{
// onTouchBegan on sprite
}
return true;
}