Mobile 在Lua中看不到按钮

Mobile 在Lua中看不到按钮,mobile,lua,coronasdk,Mobile,Lua,Coronasdk,我添加了一个徽标和几个按钮,如PLAY和CREDITS。我没有收到任何错误,我很难看到问题,我错过了什么 --Background local bg = display.newImage("background.png") --Buttons local title local playBtn local creditsBtn --Functions local Main=('') local startButtonListeners=('') --Star

我添加了一个徽标和几个按钮,如PLAY和CREDITS。我没有收到任何错误,我很难看到问题,我错过了什么

--Background   
local bg = display.newImage("background.png")  
--Buttons  
local title  
local playBtn  
local creditsBtn

--Functions  
local Main=('')  
local startButtonListeners=('')  

--Start of Functions  
function Main()  
title= display.newImage("logo.png")  
playBtn= display.newImage("playbtn.png", 130, 248)  
creditsBtn= display.newImage("creditsbtn.png", 125, 316)
titleView= display.newGroup(title, playBtn, creditsBtn)    

startButtonListeners("add")  
end

如果这是您的全部代码,您从未调用过主函数,在corona中,您不必调用主函数,main.lua将在项目开始时运行。所以试着像这样运行你的代码

--Background   
local bg = display.newImage("background.png")  
--Buttons  
local title  
local playBtn  
local creditsBtn

--Functions  
local Main  
local startButtonListeners, anotherButtonListener

--Start of Functions  
Main = function()  
   title= display.newImage("logo.png")  
   playBtn= display.newImage("playbtn.png", 130, 248)  
   creditsBtn= display.newImage("creditsbtn.png", 125, 316)
   titleView= display.newGroup()    
   titleView:insert(title)
   titleView:insert(playBtn)
   titleView:insert(creditsBtn)

   playBtn:addEventListener("tap", startButtonListeners)
   --creditsBtn:addEventListener("tap", anotherButtonListener)
end

startButtonListeners = function(event)
   --Do something here
end
anotherButtonListener = function(event)
   --Do something for the credits here
end

Main()  --Remember to actually call Main to make it run
在Lua中,没有声明的主函数,它只是按顺序运行所有内容。请记住,您不需要像在C中那样编写主函数,但更像Python,它只运行您编写的内容

编辑:你为什么不把你得到的错误贴出来,这样我们可以更好地帮助你?但是扫描代码肯定让我忘了什么。新集团线。
请参阅上面编辑的代码。

欢迎使用堆栈溢出。你能描述一下你遇到了什么问题吗?非常感谢,这很有帮助。在我打电话给Main之前,我会收到错误信息。