首页 > 其他 > 详细

cocos2d-x3.x自定义事件

时间:2016-12-31 14:32:04      阅读:103      评论:0      收藏:0      [点我收藏+]

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

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

cocos2d-x3.x自定义事件

原文:http://www.cnblogs.com/qianwang/p/6239168.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!