在cocos2dx3.X提供了自定义事件。用户可以调用相应API来实现自己所需事件的创建和分发。<p></p><p>以下是如何在lua中使用自定义事件API</p><p>
添加自定义事件监听器
local dispatcher = cc.Director:getInstance():getEventDispatcher(); --新建事件监听器 local custom_listener = cc.EventListenerCustom:create("custom", function(event) --do something end) --添加事件监听器到分发器 dispatcher:addEventListenerWithFixedPriority(custom_listener, 1);
原文地址:https://blog.csdn.net/boscof/article/details/44565867