cocos2d-x3.x自定义事件

-- 自定义事件
-- 监听:

local eventDispatcher = self:getEventDispatcher();--self为继承Node的对象

local function handleBuyGoods(event)
cclog("handleBuyGoods")
end
local listener = cc.EventListenerCustom:create("HandleKey.kDidBuyGoods", handleBuyGoods)
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)

-- 广播:

local eventDispatcher = cc.Director:getInstance():getEventDispatcher()
local event = cc.EventCustom:new("HandleKey.kDidBuyGoods")
eventDispatcher:dispatchEvent(event)

--事件机制入口:http://www.cnblogs.com/haogj/p/3784896.html

上一篇:理解RxJava:(三)RxJava的优点


下一篇:剑指Offer 替换空格