WaitLayer::init()
buttonBack->addTouchEventListener(this, toucheventselector(WaitLayer::pressBack));
程序运行时候会经常崩溃
但是如果我们给当前切换场景按钮绑定事件方式变为如下lambda表达式则不会崩溃
/buttonBack->addTouchEventListener(=](Ref ref,Widget::TouchEventType type){
this->pressBack(ref,type);
});/
如果我们把
void GameNet::removeFunc(void key,const char *actionname)
{
removeFunc((String::createWithFormat("%u",key)->getCString()),actionname);
}
void GameNet::removeAllFunc(void* key)
{
removeAllFunc(String::createWithFormat("%u",key)->getCString());
}
改为如下方式
void GameNet::removeFunc(void* key,const char actionname)
{
char str={0};
itoa((unsigned long)key,str,10);
string str1 = str;
removeFunc((str1,actionname);
}
void GameNet::removeAllFunc(void key)
{
char s={0};
itoa((unsigned long)key,s,10);
string str=s;
removeAllFunc(str);
}
那么我们前面不管用哪种触摸回调都不会崩溃。