创建自定义事件:
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto listener = EventListenerCustom::create("MyEvent",[](EventCustom *event){
CCLOG("Hello %s",(char*)event->getUserData());
});
Director::getInstance()->getEventDispatcher() ->addEventListenerWithFixedPriority(listener,1);
触发事件:
EventCustom e("MyEvent");
e.setUserData((void*)("Lidaha"));
Director::getInstance()->getEventDispatcher()->dispatchEvent(&e);