在Storyboard中看不到文字

时间:2015-07-11 18:49:09

标签: lua storyboard corona

我对Corona SDK相当新,并且正在尝试制作游戏菜单,但是当我运行代码时它只是不显示文本。我已经确定该程序可以使它达到此文件的目的。知道为什么吗?

local storyboard =  require ("storyboard")
local scene = storyboard.newScene()

display.setStatusBar (display.HiddenStatusBar)

local function ButtonTap (event)
  storyboard.gotoScene(event.target.goto, {effect="slideDown"})
  return true
end

function scene:CreateScene (event)
  local group = self.view

  -->Play Button
  local PlayBtn = display.newText ("Play",0,0)
  PlayBtn.x = display.contentHeight/2
  PlayBtn.y = display.contentWidth/2
  PlayBtn.goto = "Play"
  PlayBtn:addEventListener("tap", ButtonTap)
  group:insert(PlayBtn)

  -->Exit Button
  local ExitBtn = display.newText ("Play",0,0)
  ExitBtn.x = display.contentHeight/2
  ExitBtn.y = display.contentWidth/2 + 60
  ExitBtn.goto = "Play"
  ExitBtn:addEventListener("tap", ButtonTap)
  group:insert(ExitBtn)
end


-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
  local group = self.view

end

-- Called when scene is about to move offscreen:
function scene:exitScene( event )
  local group = self.view

end


-- Called prior to the removal of scene's "view" (display view)
function scene:destroyScene( event )
  local group = self.view

end

scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )

return scene

提前致谢:)

1 个答案:

答案 0 :(得分:0)

function scene:如果遵循标准命名约定,CreateScene(event)应该是函数scene:createScene(event)。 Lua区分大小写。在:

scene:addEventListener( "createScene", scene )

您使用的是小写" c",但在功能中,您使用的是大写" C"。这些必须匹配,Corona标准将采用小写版本。