繁体   English   中英

电晕错误:尝试调用全局“ startButtonListeners”

[英]Corona error: attempt to call global “startButtonListeners” <a nil value>

我正在用电晕制作一个主菜单,但是遇到一个错误,这使我发疯。

编译器使我难以理解它是什么,但是我可以从中指出两个问题:

  • 尝试调用全局“ startButtonListeners”
  • 函数“ startButtonListeners”中的[C]

这是代码部分:

 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM