-- 自定义事件
-- 监听:
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)