我想在Touch Begin上调用CCMenuItem,但它会在触摸端调用如何解决这个问题?
我的代码就像这样
CCMenuItemImage * rld = CCMenuItemImage :: itemFromNormalImage(“bomb.png”,“bomb.png”,this,menu_selector(MyScene :: boom));
我想在touchbegin上调用繁荣功能....
答案 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 ::吊杆));
}