代码:
程序.h
public:
virtual bool init();
static cocos2d::CCScene* scene();
CREATE_FUNC(ProgScene);
void spriteMoveFinished(CCNode* sender);
void endCallback(CCObject* pSender);
void endCallbackWork(CCNode* pSender);
程序.cpp
void ProgScene::spriteMoveFinished(CCNode* sender)
{
CCMessageBox("Sprite Move Finished","Sprite Move Finished");
this->runAction(CCCallFuncN::actionWithTarget( this, callfuncN_selector(ProgScene::endCallbackWork))); // WORK
// this->runAction(CCCallFuncN::actionWithTarget( this, callfuncN_selector(ProgScene::endCallback))); // NOT WORK
}
void ProgScene::endCallback(CCObject* pSender)
{
...
CCMessageBox("From endCallback","From endCallback");
}
void ProgScene::endCallbackWork(CCNode* sender)
{
...
CCMessageBox("from endCallbackWork","from endCallbackWork");
}
我是cpp的初学者,请帮助我。
如何从方法调用方法 endCallback actionWithTarget
?当我使用
this->runAction(CCCallFuncN::actionWithTarget( this, callfuncN_selector(ProgScene::endCallback)));
它返回:
error C2440: 'type cast' : cannot convert from 'void (__thiscall ProgScene::* )(cocos2d::CCObject *)' to 'cocos2d::SEL_CallFuncN'
1> Pointers to members have different representations; cannot cast between them
endCallbackWork
很好的合作
this->runAction(CCCallFuncN::actionWithTarget( this, callfuncN_selector(ProgScene::endCallbackWork)));
也许我可以使用以下方式以外的其他方式?
this->runAction(CCCallFuncN::actionWithTarget( this, callfuncN_selector(ProgScene::endCallback)));