Search code examples
cocos2d-x

call CCMenuiItem function on touchbegan in cocos2dx


i want to call CCMenuItem on Touch Begin but it calls on touch end how to solve this??

my code is like this

CCMenuItemImage* rld=CCMenuItemImage::itemFromNormalImage("bomb.png","bomb.png",this,menu_selector(MyScene::boom));

i want to call boom function on touchbegin....


Solution

  • in your touchBegan

    CCCallFuncN* functionCall = CCCallFuncN::actionWithTarget(this,callfuncN_selector(MyScene::boom));
    this->runAction(functionCall);
    

    or simply just

    this->boom(this);