@pengjx 写道:
请问这是怎么回事啊?
local function onMenuGameOver ()
cc.Director:getInstance ():getEventDispatcher ():dispatchCustomEvent ("component game over")
end
local function onGameOverEvent (event)
self:getApp ():enterScene ("MainScene")end local eventDispatcher = cc.Director:getInstance ():getEventDispatcher () layer._listener1 = cc.EventListenerCustom:create ("component game over", onGameOverEvent) eventDispatcher:addEventListenerWithFixedPriority (layer._listener1, 1)
每次调用onMenuGameOver 退出场景后,下次再进这个场景,退出就会报如下错误:
[LUA-print] [string "app/views/LoginScene.lua"]:105: attempt to call method 'getApp' (a nil value)
stack traceback:
[C]: in function 'dispatchCustomEvent'
[string "app/views/LoginScene.lua"]:102: in function <[string "app/views/LoginScene.lua"]:101>而且每多进一次,退出的时候,这个错误就会多报一次,感觉是什么东西没释放干净。
直接加个按钮执行: self:getApp ():enterScene ("MainScene"),就不会报错。
但是我这个dispatchCustomEvent ,是为了另外一个view文件里调用的。所以用了事件监听。用事件监听就会报那个错。
帖子: 1
参与者: 1