コード:
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の初心者です。助けてください。
メソッドからメソッド 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)));