Hi ! I’m currently working on a game using Corona Sdk and creating levels using Tiled thanks to the Ponytiled customs (https://github.com/ponywolf/ponytiled) .
Game has 8 levels and i would like to know which could be the eaasiest way to unlock a passed\reached level button in the main menu of the game and save it permantly?
I’ve tried this one (https://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/) " Building a Level Selection Scene" which is pretty good, but actually not working very well for my game.
But since i’m already using a .json file to load my menu ( similar to title.json in ponytiled), is there any way i could edit a line of that file with a lua function, chnging an object.isVisible from false to true?
This edit should be permanent, ich means that when i quit the game it gets saved.
i’ll bring some lines from the Ponytiled ‘‘title.json’’ hopefully trying to be more clear:
**-- Load our UI**
** local uiData = json.decodeFile( system.pathForFile( "scene/menu/ui/title.json", system.ResourceDirectory ) )**
** ui = tiled.new( uiData, "scene/menu/ui" )**
** ui.x, ui.y = display.contentCenterX - ui.designedWidth/2, display.contentCenterY - ui.designedHeight/2**
This lines work pretty good because with just:
**ui:findLayer( " LEVEL 2 BUTTON" ).isVisible = true**
i can now unlock the LEVEL 2 BUTTON , but obviosly the line “visible”:false,
in the title.json doesn’t get edited.
so is there a way to edit the line “visible”:false, in title.json to “visible”:true,?
Maybe using the
**`local` `file = ` `io.open` `(uiData , ` `"w"` `)`**
** **
**` ` `if` `file ` `then`**
**` ` `file:write( json.encode( "scene/menu/ui/title.json" ) )`**
**` ` `io.close( file )`**
or something similar that i’ve missed?
i know it seems pretty strange, but it could be a really good way to unlock levels.
Thank you!