[英]Corona error: attempt to call global “startButtonListeners” <a nil value>
我正在用電暈制作一個主菜單,但是遇到一個錯誤,這使我發瘋。
編譯器使我難以理解它是什么,但是我可以從中指出兩個問題:
這是代碼部分:
function scene:enterScene(event)
local group = self.view
startButtonListeners('add')
function startButtonListeners(action)
if(action == 'add') then
aboutBtn:addEventListener('tap', showCredits)
startBtn:addEventListener('tap', startBtn)
end
local function onSceneTouch( self, event )
if event.phase == "began" then
storyboard.gotoScene( "scene1", fade, 500 )
return true
end
end
end
將函數startButtonListeners
的位置更改為結尾; 函數定義完成后:
scene:enterScene(event)
local group = self.view
function startButtonListeners(action)
if(action == 'add') then
aboutBtn:addEventListener('tap', showCredits)
startBtn:addEventListener('tap', startBtn)
end
local function onSceneTouch( self, event )
if event.phase == "began" then
storyboard.gotoScene( "scene1", fade, 500 )
return true
end
end
startButtonListeners('add')
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.