How do I save the current frame ? Like when I am on level 3 and I exit. And I log back on the game. I am still on level 3. without clicking a button to save or anything. It just has to save as soon as a new frame is loaded
Printable View
How do I save the current frame ? Like when I am on level 3 and I exit. And I log back on the game. I am still on level 3. without clicking a button to save or anything. It just has to save as soon as a new frame is loaded
You'll need some sort of external aid to save your progress.
An INI file just would serve this simple purpose.
On each frame add:
start of frame
---> set current file (apppath$/yourini.ini)
---> set current item (level_reached)
---> set value (frame number)
On first frame, just add:
start of frame
+ compare two general values (ItemValue( "Ini","level_reached") > 1
---> go to frame number (ItemValue( "Ini","level_reached")
Be aware that a simple INI is easily "hackable", if you don't take adequate measures
(saving a "passphrase" for each frame, instead of frame number, i.e.)
Hey Schro,
I always see a warning when it comes to INI Files. I understand that this is the easiest way to save files so it must be easy to hack, but how would someone hack a file? Not that I want to be able to do it, but so I know why its so important to take steps to protect my work.
You can open the INI file with a text editor, such as notepad.
Marv
Wow! So they can open it that easily and just delete or add or whatever. That's crazy.
I believe you can encrypt the ini file with blowfish, or something similar.
Anyways, I would not be too bothered about that. I chose not to have any protection. If someone wants to mess with the save file or dialogues file then I'll let them. Nothing away from me. :)
Though, for competitive games it is all different story.
You can store all the object states you want to keep between frames to an array object (memory) save them on frame exit and load them on frame enter. If you want to create save files to load after you closed the game and reopened it - the array objects can also write array files to disk.
Ini files are another way to do it, but I have found that with many objects arrays are way faster.
If you dont want to spend ages laboriously setting up each variable you want saved, there is an automated load and save game template at the clickstore:
http://clickstore.clickteam.com/easy-load-save-system
It does all the work, you just add a "DATA" qualifier to an objects and all of its variables and strings can get saved to memory or to an array file by calling a fastloop.
If you want to, It can also dump all the array stored information to an ini file, so you can see whats going on.
Agreed, arrays are definitely a better way to handle many things, and save states too (faster and more protected)
but for new users I would suggest INIs, they're just easier to understand, inspect and setup
(and, as JesseM said, for single player games that's up to the player, if he wants to "cheat" and maybe ruin his gaming experience X))
@Emerson:
exactly as Nivram said, INIs are just text files, so anyone can open, mess-up and save.
If you save your player's score as:
[player_score=100]
it can easily become
[player_score=99999999999]
XD
particularly in this request,
when the INI saves current reached level (frame number),
if saved as a simple number the player can easily reach last levels just by changing a number,
that's something to think upon, if you're worried about cheating in your games!
I forgot to say it has to be for android. Will this method work for android ? I noticed a old android ini extension
Yes, both INIs and Arrays are supported on Android