Now that we have renamed our game file, let's add in a scene transition so that our game is not stuck at the Game Over screen once game play is over. To change the screen, perform the following steps:
In our
maingame.lua
file, add in a new variable calledlocal menuBtn
, where all the other variables are initialized in the beginning of the code. Inside thecallGameOver()
function, add the following lines after thehighScoreText
code:local onMenuTouch = function( event ) if event.phase == "release" then audio.play( btnSound ) composer.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 = "", -- Can use any font available per platform font = "Helvetica",...