static int count = 0;
//定义加载事件回调
auto callBack = =](EventCustom* evt)
{
count++;
loadingbar->setPercent(count);
log(“catch an custom event!!”);
};
cocos2d::EventListenerCustom* customEvt = EventListenerCustom::create("LAOD_PRECENT_EVENT", callBack);
//注册自定义事件(处理优先级为12)
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(customEvt, 12);
//抛出自定义事件
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("LAOD_PRECENT_EVENT");
直接跑当前场景是有效的
但是我切换场景的时候,替换到当前场景,发现没有效果,请教什么问题