在cocos2dx中调用touchbegan上的CCMenuiItem函数

时间:2012-08-21 20:32:15

标签: cocos2d-x

我想在Touch Begin上调用CCMenuItem,但它会在触摸端调用如何解决这个问题?

我的代码就像这样

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

我想在touchbegin上调用繁荣功能....

2 个答案:

答案 0 :(得分:0)

在你的touchBegan中

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

或只是

this->boom(this);

答案 1 :(得分:0)

<强> MyLayer.cpp

MyLayer :: MyLayer()

{

这 - &GT; setTouchEnabled(真);

}

   void MyLayer::registerWithTouchDispatcher(void)
 {
     CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this,0);

 }

void MyLayer :: boom()

{

CCLog(“智能是新的性感”)

}

 void MyLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{

CCMenuItemImage * menuItemImage = CCMenuItemImage :: itemFromNormalImage(“bomb.png”,“bomb.png”,                                            此,menu_selector(MyLayer ::吊杆));

}