Cocos2d-x 3.x Lua自定义事件

    local function eventCustomListener1(event)
        local str = "Number is "..event._usedata
        print(str)
    end
    local eventDispatcher = self:getEventDispatcher()
    local listener_custom = cc.EventListenerCustom:create("custom_event",eventCustomListener1)
    self._listener1 = listener_custom
    eventDispatcher:addEventListenerWithFixedPriority(listener_custom, 1)
    local event = cc.EventCustom:new("custom_event")
    event._usedata = string.format("%d",10)
    eventDispatcher:dispatchEvent(event)

 

posted on 2014-08-22 16:04  CoolExp  阅读(79)  评论(0)    收藏  举报

导航