-
What if you use the array object? It has a save action. I created an autosave with it in one of my games. You would just have to create a condition which would cause the saving to occur. So, right before game closes, it saves the current timer value. Then you load from the array the next time the game is started and set the timer to the loaded value.
-
Cimics,.I will give that a shot.
-
An array object is unsuitable for a non-tabular data, e.g., if you wouldn't put it in a grid, you shouldn't use an array.
INI is better for this purpose, as it is various settings, rather than sets of one type of data, which the Array object is good for.
+On Start of Frame
-INI: Set current file Apppath$+"Data.ini"
-Timer: Set timer to ItemValue("INI", "Timer")
+On save event
-INI: Set value "Timer" to ItemValue("INI", "Timer")+timer
-
Thanks SortaCore,.i'll give that a try.
-
Also, if you want to prevent someone from editing that file, you can use ini++ or an array object with built in encryption. Though for maximum compatibility the default ini object would be safer (if you care about exporters). Don't know if ini++ or something similar has been ported to Flash/iOS/etc
-
The problem I'm having with all of this, is that the game has multiple levels (20) and I just don't understand how to set this up for each level. To be totally honest I don't understand it at all. I tried using Sortacores example and nothing happened? Do I need to use a counter also in the example above or a few counters to record hours, minutes, secs? I'm really clueless.
Here is an example one of the members did for selecting levels that I used in my game and it works perfect and I understood it. This is how my game is setup using that example,.but would like to add in a total "timeplayed" feature to the game in , hours, minutes, seconds,.or just minutes and seconds if it would make things easier. Even if a player is on say level 10,.I want the total time to be seen throughout the game and when the player exits and comes back later to play the game again, I would like it to keep adding the time to the current time played and so on.
Also,.since I'm using an INI now,.can I just use the same one or does another need to be added to do the time saving feature?
http://www.mediafire.com/?0482usrzg5xr3bc
-
1 Attachment(s)
Here, check this example:
-
LB,.very nice indeed. Thank you for taking the time to do this. It works just like I was thinking. Now I understand how it's done. I have one question,.where would the INI be stored. I can't seem to find it?
Thanks to all of you who posted in this thread. You're all a big help!
-
Apppath$ is the macro for the Application's Path. That'll get what folder the program is running in.
e.g. if your program is C:\Program Files\MyGame\Fun.exe, Apppath$ will be C:\Program Files\MyGame\.
-
By default it would be stored in the AppData folder. It's a hidden folder in your windows user folder so you can't see it unless you enable that in folder options. Obviously you can change the file path to be saved if you don't want it in there.