環境: cocos2d-x + lua 3.0beta2
首先聲明全局變量
UIEventDispatcher = cc.EventDispatcher:new()
然后在使用的地方dispathCustomEvent
UIEventDispatcher:dispatchCustomEvent("test","test")
但是拋出如題的錯誤
查看此時 UIEventDispatcher ~= nil
如果在聲明的地方馬上調用,就沒有問題,難道是否自動釋放了
在聲明的下面加上一句 UIEventDispatcher:retain()
看來是cocos2d-x的自動釋放機制
具體原因,待查