Sorry about the code, It was formatted when I loaded it up but when I hit post it got jumbled. The row in red is the row throwing the problem.
–LEVEL TRACKER
local composer = require( “composer” )
local scene = composer.newScene()
–BUNCH OF CODE
– Button handler to cancel the level selection and return to the menu
local function handleCancelButtonEvent( event )
if ( “ended” == event.phase ) then
composer.gotoScene( “menu”, { effect=“crossFade”, time=333 } )
end
return true
end
– Button handler to go to the selected level
local function handleLevelSelect( event )
if ( “ended” == event.phase ) then
– ‘event.target’ is the button and ‘.id’ is a number indicating which level to go to.
– The ‘game’ scene will use this setting to determine which level to load.
– This could be done via passed parameters as well.
--mydata.settings.currentLevel = event.target.id
local prevgameLives = gameLife.loadgameLives(“gameLivesfile.txt”)
prevgameLives = tonumber(prevgameLives)
if prevgameLives > 0 then
local levNumber = tonumber(event.target.id)
currentLevel = levNumber
myData.settings.currentLevel = levNumber
utility.saveTable(myData.settings,“settings.json”)
local scene = (“level”…levNumber)
composer.removeScene( scene, false )
composer.gotoScene( scene, { effect = “crossFade”, time=333 } )
end
end
end
Thanks