所以我在 Corona SDK 中制作了一个应用程序,当我单击试图加载我的第一级的按钮时出现错误。
这是我的代码:
主程序.lua
local storyboard = require "storyboard"
storyboard.gotoScene("menu")
菜单.lua
local storyboard = require ("storyboard")
local scene = storyboard.newScene()
function scene:createScene( event )
local screenGroup = self.view
-- Background
bg = display.newImage("images/bg.png")
bg.x = display.contentCenterX
bg.y = display.contentCenterY
screenGroup:insert(bg)
-- Title
title = display.newImage("images/title.png")
title.x = display.contentCenterX
title.y = display.contentCenterY - 100
screenGroup:insert(title)
-- Play game
play = display.newImage("images/playgame.png")
play.x = display.contentCenterX - 170
play.y = display.contentCenterY - 27
screenGroup:insert(play)
-- About Us
about = display.newImage("images/about.png")
about.x = display.contentCenterX - 100
about.y = display.contentCenterY + 40
screenGroup:insert(about)
-- Level Select
select = display.newImage("images/select.png")
select.x = display.contentCenterX
select.y = display.contentCenterY + 100
screenGroup:insert(select)
end
function start(event)
if event.phase == "began" then
storyboard.gotoScene("level1", "fade", 400)
end
end
function start2(event)
if event.phase == "began" then
storyboard.gotoScene("about", "fade", 400)
end
end
function start3(event)
if event.phase == "began" then
storyboard.gotoScene("selectlvl", "fade", 400)
end
end
function scene:enterScene(event)
play:addEventListener("touch", start)
about:addEventListener("touch", start2)
select:addEventListener("touch", start3)
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
return scene
我的 level1.lua 中有 0 个代码
我得到的错误是这样的:
Runtime error
?:0: attempt to concatenate global 'sceneName' (a nil value)
stack traceback:
[C]: ?
?: in function 'gotoScene'
...s\corona projects\stickman obsticale course\menu.lua.42: in function
<...s\corona projects\stickman obsticale course\menu.
感谢阅读,我希望你能找到答案,因为我不能:)