这样写传入的tmpLayer 报错了 mainLayer是全局变量,开始这样this->getScheduler()->schedule(&](float dt),可以引用,但是我想删除fail_2 在回调里面,有不设置tag可以解决的方法么?
源码:
Layout *fail_2 = (Layout *)(cocostudio::GUIReader::getInstance()->widgetFromJsonFile(“bigFishEatSmallFish/fail_2.ExportJson”));
mainLayer->addChild(fail_2);
Layer *tmpLayer = mainLayer;
Layer *tmpThis = this;
this->getScheduler()->schedule(&fail_2 , &tmpLayer ,&tmpThis](float dt){
Layout *fail_1 = (Layout *)(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("bigFishEatSmallFish/fail_1.ExportJson"));
tmpLayer->addChild(fail_1);
tmpLayer->removeChild(fail_2);
Button *replayability = (Button *)(Helper::seekWidgetByName(fail_1,"replayability"));
replayability->addTouchEventListener(tmpThis,toucheventselector(GameScene::touchEventFailOrSeccess));
Button *next = (Button *)(Helper::seekWidgetByName(fail_1,"back"));
next->addTouchEventListener(tmpThis,toucheventselector(GameScene::touchEventFailOrSeccess));
},this,0,1,3,false,"fail_2");