addTouchEventListener函数参数必须要求static函数?

其实我之前在贴吧也问过……

我从cocostudio中导入了一个带有button的UI,现在想要给button加入响应事件,但是addTouchEventListener函数的参数如果不是static的函数就无法编译通过,说“function call missing argument list” 让我试着加个&

但是加上&也不对,又提示我term does evaluate to a function taking two arguments

我后来试着给这个函数加上了static,也就通过了,还能正常运行,可是不能使用this非常的不爽,所以还是想要大家帮帮忙看是哪里出错了。

 


class B : public cocos2d::Layer 
{ 
public: 

static cocos2d::Scene* createScene(); 
virtual bool init(); 

static BuyBuilding* create(); 

static void Callback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type); 

private: 
cocos2d::ui::Layout* storeUI; 
rapidjson::Document doc; 


}; 

void B::init() 
{ 
storeUI = dynamic_cast<ui::Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("kkk.json")); 

storeUI->getChildByName("Image_2")->getChildByName("Button_4")->addTouchEventListener(B::Callback); 
} 

void B::Callback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){};