環境: cocos2d-x + lua 3.0beta2
想使用CCNotification, 發現3.0已經替換為CCEvent, 晃了一眼設計,不錯
原來在C++ 上自己也實現了一套Event,因為不滿意CCNotification 沒有優先級,沒有自定義分類(比如UI,Logic),不能攜帶數據,現在3.0的設計基本滿足了需求
使用中還是發現一點問題 (self is a CCLayer):
self:getEventDispatcher():addCustomEventListener(EVENT_XXX, function() self:callbackOfXXX() end)
異常:Assertion failed: (false), function lua_cocos2dx_EventDispatcher_addCustomEventListener /lua_cocos2dx_auto.cpp, line 5610.
暫時沒有理解為什么要assert,有空再注釋掉試試
臨時使用如下方法:
local listener1 = cc.EventListenerCustom:create(EVENT_XXX, function() self:callbackOfXXX() end) self:getEventDispatcher():addEventListenerWithFixedPriority(listener1, 1)
如題待解。。。