代码:
prog.h
public:
virtual bool init();
static cocos2d::CCScene* scene();
CREATE_FUNC(ProgScene);
void spriteMoveFinished(CCNode* sender);
void endCallback(CCObject* pSender);
void endCallbackWork(CCNode* pSender);
prog.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的初学者,请帮助我。
如何从方法actionWithTarget
调用方法endCallback?
当我使用
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)));