I’m working to figure out how I’m going to implement the ability to pause, save and load the state of my game. The Jon Beebe tutorial from a few weeks ago is exceptionally enlighting on the “big picture” of implementing this:
http://www.coronalabs.com/blog/2012/07/17/using-system-events-to-save-app-state/
Does anyone have any thoughts regarding the “nuts and bolts” of pausing, saving and loading? I plan on using an onSystemEvent() function much as he shows in his article:
[lua]local function onSystemEvent( event )
if (event.type == “applicationExit”) then
save_state()
elseif (event.type == “applicationOpen”) then
load_saved_state()
elseif (event.type == “applicationSuspend”) then
pause_game()
end
end
Runtime:addEventListener( “system”, onSystemEvent )[/lua]
I guess I should be using tables to track each type of “thing” I have in my game (the Player, NPCs, projectiles, the map, etc.)? Save the tables on suspend or exit and then reload them when resumed/reloaded?
I currently have a table that houses all of my NPCs. I’m guessing I should have one for projectiles as well? Basically any “thing” I have in the game?
I plan on using storyboard for transitioning from screen to screen (still just building my base systems). Are there any considerations I should keep in mind with the Storyboard API and pausing/saving/loading?
Are there any sample games that would be best to look at? I currently don’t have a “game loop” in my game. It seems like having one might make this easier. Any thoughts?
Thanks for your help in getting a better grasp of how to manage this. [import]uid: 105707 topic_id: 29341 reply_id: 329341[/import]
[import]uid: 105707 topic_id: 29341 reply_id: 118074[/import]