Now that we have renamed our game file, let's add in a scene transition so that our game is not stuck on the Game Over screen once gameplay is over.
In our maingame.lua
file, add in a new variable called local menuBtn
where all the other variables are initialized in the beginning of the code. Inside the callGameOver()
function, add the following lines after the highScoreText
code:
local onMenuTouch = function( event ) if event.phase == "release" then audio.play( btnSound ) storyboard.gotoScene( "mainmenu", "fade", 500 ) end end menuBtn = ui.newButton{ defaultSrc = "menubtn.png", defaultX = 60, defaultY = 60, overSrc = "menubtn-over.png", overX = 60, overY = 60, onEvent = onMenuTouch, id = "MenuButton", text = "", font = "Helvetica", textColor = { 255, 255, 255, 255 }, size = 16, emboss...