Save System

For questions about using Classic.

Post » Fri May 27, 2011 8:15 pm

I have two questions:
1.) How do you make a save system where you can click a save button, quit the game and when
you get back on the game, everything is exactly the same as when you saved.
2.) How do you make it where you have everything you had when you switch layouts. (like going
out of a building)
B
5
S
3
G
4
Posts: 189
Reputation: 2,910

Post » Fri May 27, 2011 8:59 pm

I'm an INI fanatic, so I'd recommend using those for both tasks (save and load on layout change as well as exit).

Here are some INI tutorials:
Basic INI Use: [url:1m1mfqhv]http://www.scirra.com/forum/viewtopic.php?f=8&t=4328&hilit=Save[/url:1m1mfqhv]
INI File Protection: [url:1m1mfqhv]http://www.scirra.com/forum/viewtopic.php?f=8&t=4549&hilit=Save[/url:1m1mfqhv]
INI Level Loading/Editing: [url:1m1mfqhv]http://www.scirra.com/forum/viewtopic.php?f=8&t=1721[/url:1m1mfqhv]
Achievements With INI Files: [url:1m1mfqhv]http://www.scirra.com/forum/viewtopic.php?f=8&t=9418[/url:1m1mfqhv]
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri May 27, 2011 9:02 pm

Thanks Jay Jay :D This will be helpful for sure. :mrgreen:
B
5
S
3
G
4
Posts: 189
Reputation: 2,910

Post » Fri May 27, 2011 9:17 pm

[quote="Granhunter101":ymayawpm]Thanks Jay Jay :D This will be helpful for sure. :mrgreen:[/quote:ymayawpm]

No problem, if you get stuck with INI files just send me a PM and I'll try to make a tutorial for you when I next have some free time :)
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Sat May 28, 2011 2:56 am

There's a built in save feature, and i think it's supposed to work quite well, but check the bugtracker. I've had poblems with it in the past.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Sat May 28, 2011 3:19 am

[quote="Attan":6vgjzo02]There's a built in save feature, and i think it's supposed to work quite well, but check the bugtracker. I've had poblems with it in the past.[/quote:6vgjzo02]

In some of my own tests, I've found that it tends to load layouts with very few assets quite well, but when you get into layouts with a lot of on-screen assets it has trouble. In my own case, save and load has actually caused the game to malfunction completely in very strange glitchy ways. Lots of crashes, too.
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Sat May 28, 2011 3:39 am

[quote="MrMiller":3re9mbxh][quote="Attan":3re9mbxh]There's a built in save feature, and i think it's supposed to work quite well, but check the bugtracker. I've had poblems with it in the past.[/quote:3re9mbxh]

In some of my own tests, I've found that it tends to load layouts with very few assets quite well, but when you get into layouts with a lot of on-screen assets it has trouble. In my own case, save and load has actually caused the game to malfunction completely in very strange glitchy ways.[/quote:3re9mbxh]

I haven't ever used the built-in save feature myself (I have used INI's like Jayjay mentioned though), but would it be possible to have a very small, bare-bones save screen layout to save and load from at runtime?

Like, you hit pause and transition to a separate save/load layout with a simple UI. Hit the save button, and it stores all the globals you need. Hit the load button to load them. Then you can transition to whatever level is stored in your "currentLevel" global or whatever, and populate any scores, powerups, stats, or whatever with your other globals. Would that be one way around the lots-of-assets-to-load problem?



Edit:
By the way, if you are using INI's to build levels (by saving the size and position of platforms and enemies, for instance), then it is possible to store those in the game itself with simple hidden text objects by useing the Text Manipulator and the File objects.

Step 1:
On level load, you read the INI file information stored in the text object.

Step 2:
Use the Text Manipulator to save that text information to a temporary INI file in the game directory.

Step 3:
Use the INI object to read the info from the file you just created and do your level building loop.

Step 4:
Use the File object to delete the INI file.

This can all be done in one tick, seamlessly. In fact I'm not even certain that it writes an actual file to the drive because it's being created, stored in memory, used, and deleted all in one fell swoop before Windows has a chance to process the write command. Anyway, this is how I did dynamic level loading for my game Vert, which only uses one layout for the entire game (even though there are only two levels :P).

Of course, with Rojo's new Resource plugin you can just store whatever INI files you want in the .exe itself without any fancy tricks like this, I'm just saying. Well, obviously you can't CHANGE the contents of an INI stored in the exe, but you can save basic level building data.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat May 28, 2011 4:15 am

[quote="deadeye":1r41j7hh]
I haven't ever used the built-in save feature myself (I have used INI's like Jayjay mentioned though), but would it be possible to have a very small, bare-bones save screen layout to save and load from at runtime?[/quote:1r41j7hh]

Yeah, you can make a separate layout and set your events for saving and loading right in there. I just ran a test today of that in CC1. I only had a few assets in the layout I wanted to load, but it worked except that if I had two commands tied to the same button (i.e. left mouse button saves in layout 1, and left mouse button loads in layout 2 and also loads a picture from file) it causes images in the loaded layout to enlarge and pixellate, and then when I click the left mouse button to load, it crashes.

[quote="deadeye":1r41j7hh]
Like, you hit pause and transition to a separate save/load layout with a simple UI. Hit the save button, and it stores all the globals you need. Hit the load button to load them. Then you can transition to whatever level is stored in your "currentLevel" global or whatever, and populate any scores, powerups, stats, or whatever with your other globals. Would that be one way around the lots-of-assets-to-load problem?[/quote:1r41j7hh]

That sounds like a plan. I'm definitely going to give that a shot as I would like to be able to get a precise save and load down to the last saved x and y position. Though, it seems like .ini is the path of least resistance for most games where all you need to do is save values/scores. It's quite possibly a larger matter of the .ini object being more functional than Save/Load and that the Save/Load function still has some critical bugs to be worked out. I mean, I've written to and loaded things from .ini with no problem whereas I've had glitches and crashes with the same things using Save/Load.
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Sat May 28, 2011 4:37 am

The Game Jolt Achievements plug now has web storage, which means you can store game saves online in text format.
[url:2jsdthqv]http://gamejolt.com/developers/achievements/[/url:2jsdthqv]

The method is much like ini, where you designate a key, and data for the key. You can not make multiple items like ini, but you can make as many keys/groups as you like, and there is user storage, as well as game storage ie global data.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests