How to save/load
by Komar "FLy" Sergey · in iTorque 2D · 06/12/2009 (8:03 am) · 25 replies
Hello, are there any tutorials to learn how can I save/load my game on iPhone using iTGB? Have found some threads on forum, but its not enough for me to understand, I need a wide explanation.
#22
I drag and drop animated sprites onto my level. Assign them a MonsterBehavior and then give them their MonsterID. The Behavior then uses this monster id to query the database to load all of the monsters attributes, AI, randomly populate it's loot table etc. This means if I want to tweak a graphic, sound, or attribute I just change one cell in a spreadsheet and then regenerate the database.
For saving/loading level state I can then just simply have a writeable database and write the monster's ID and transient state variables to this new database enabling very easy level save/load.
I've also really like the database because I can use transactions to ensure if the phone is interrupted etc during a save it doesn't destroy the save game etc.
Also if you ever plan to do backup of save games etc the database is perfect because your entire save data is in a single file.
For really simply games where you serialize the entire scene graph and then deserialize it then yes a database would be pointless.
However except for the simplest of games you always need a way to store relational style information and a database is perfect for this kind of stuff.
My game is only a few weeks from release and I think once you see it you'll understand why a database was the only option. I have 500+ row spreadsheet just listing the monsters, items, enhancements, abilities, quests etc that I use to generate the database. With randomization, prefixes, suffixes etc there are an incredible amount of possibilities of items etc.
08/25/2009 (6:07 pm)
Depends on how you create/structure your game.I drag and drop animated sprites onto my level. Assign them a MonsterBehavior and then give them their MonsterID. The Behavior then uses this monster id to query the database to load all of the monsters attributes, AI, randomly populate it's loot table etc. This means if I want to tweak a graphic, sound, or attribute I just change one cell in a spreadsheet and then regenerate the database.
For saving/loading level state I can then just simply have a writeable database and write the monster's ID and transient state variables to this new database enabling very easy level save/load.
I've also really like the database because I can use transactions to ensure if the phone is interrupted etc during a save it doesn't destroy the save game etc.
Also if you ever plan to do backup of save games etc the database is perfect because your entire save data is in a single file.
For really simply games where you serialize the entire scene graph and then deserialize it then yes a database would be pointless.
However except for the simplest of games you always need a way to store relational style information and a database is perfect for this kind of stuff.
My game is only a few weeks from release and I think once you see it you'll understand why a database was the only option. I have 500+ row spreadsheet just listing the monsters, items, enhancements, abilities, quests etc that I use to generate the database. With randomization, prefixes, suffixes etc there are an incredible amount of possibilities of items etc.
#23
I desperately need a database and also would pay $$$ for such a kit/resource!
08/26/2009 (8:40 am)
@BretQuote:I'm considering writing a kit or resource for using SQLite database to serialize objects and save user properties to files. Would anyone be interested in something like this? Depending on the demand I might do a simple resource or a full blown kit.This would be heaven :)
I desperately need a database and also would pay $$$ for such a kit/resource!
#24
08/26/2009 (12:48 pm)
I'm swamped right now but in a couple weeks I'll put together a simple resource for a basic scenario. If someone still wants something more then I'll consider doing a full kit you can buy. I'm not sure how you list kits on GG but if there is enough interest I'll do it. I'm beginning to really understand the iTGB code base so this kind of stuff is really easy to do.
#25
Such statements distinguish the wizards from the infantry :)
I can't wait!
08/26/2009 (3:58 pm)
Quote:so this kind of stuff is really easy to do.
Such statements distinguish the wizards from the infantry :)
I can't wait!
Torque 3D Owner Ronny Bangsund
Torque Cheerleaders