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

posted @ 2016-12-31 13:46  黔王  阅读(494)  评论(0编辑  收藏  举报