Savegame/Loading for PC Game

Get help using Construct 2

Post » Thu Nov 12, 2015 3:32 am

Hey there,

Now i created a loading/saving menu in my project, which is gonna be a pc-game. I set up 5 text boxes in my loading screen. Now i'm wondering, how i can get
the savestate informations like, player,some stats,playing-time and maybe a screenshot in there?

Any suggestions?

Thanks in advance!
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Thu Nov 12, 2015 9:48 am

Maybe make an ID system(Also making the player able to save to a name) using constructs function and random features(if you want multiple save files). and use an array and/or LocalStorage keys. Since it's a PC game I recommend using NW.js, it makes it easier and cleaner to set up some "safe" file directories. This will also make it easier for players to share save files. If you are making it for NW.js dont use localstorage.
B
8
S
2
Posts: 24
Reputation: 536

Post » Thu Nov 12, 2015 12:09 pm

@bunnehboy thank you guy for your advice! i think i have to research some more about all that stuff, cause i havent worked with arrays before!
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Thu Nov 12, 2015 7:35 pm

Hi @PulvererPeter,

I recently wrote a small tutorial about saving/loading game with NW.js, maybe it could help you a little ;-)

https://www.scirra.com/tutorials/4870/save-and-load-game-in-a-specific-folder-using-nwjs-node-webkit

At least, it could show you some basic stuff and help you understanding how it works.
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
6
G
3
Posts: 70
Reputation: 2,573

Post » Thu Nov 12, 2015 11:27 pm

@ratmaster wow, this is great, gonna read it as soon as i can :) thank you so much and keep on doing that stuff, really helpful!
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Fri Nov 13, 2015 6:56 am

@ratmaster i just made a quick capx for trying your method, but i cant get the loading of the json file to work. can you tell me what im doing wrong?

https://
drive.google.com/file/d/0B-Ksnwlyt36SdlNlcXhwY3ZhLUU/view?usp=sharing
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Fri Nov 13, 2015 10:13 am

@PulvererPeter
I'm glad it could help you a little ;)
I just had a quick look at your CAPX file, and I see where the problems are :

In your file, you wrote :
On save complete -> NWjs | Write "" to file NWjs.UserFolder&"\Test\Slot1"

- First, with this you try to write in "Slot1", but it must be a file, so maybe you should name it "Slot1.something" (you forgot to precise a file extension, so maybe no file was created)
- Also, you try to write "" (an empty string...) so even if your file was created it would be EMPTY, so nothing could be loaded from it ^^'
-> You have to use the SaveStateJSON expression to write the savestate

=> with something like On save complete -> NWjs | Write SaveStateJSON to file NWjs.UserFolder&"\Test\Slot1.something" it should work just fine
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
6
G
3
Posts: 70
Reputation: 2,573

Post » Fri Nov 13, 2015 10:19 am

And you have to set "NW.js" as preview browser or it will not work ! (the first link in my tutorial explains how to install it if you haven't done it yet)
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
6
G
3
Posts: 70
Reputation: 2,573

Post » Fri Nov 13, 2015 11:47 am

@Ratmaster man i'm so thankful, you really helped me out! with your advice i could finally get it working fine :) thank you! i have one question though, what exactly is the difference between the normal "system-save and load" and the "json-save and load"?
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Fri Nov 13, 2015 2:33 pm

@PulvererPeter

I'm glad I could help you :D

Well, the normal "system save and load" uses json too, but it stores data in either WebStorage or IndexedDB
(I'm not really sure where it is exactly), which are in theory "permanent storages" and are not affected by the user clearing their cache.

However if he uses a program such as CCleaner, the savegame may be erased... (that's what appened to me ^^')

So to avoid problems and prevent the user to lose his savegame, it's important to save the game in a file, especially if your game is a desktop application.
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
6
G
3
Posts: 70
Reputation: 2,573

Next

Return to How do I....?

Who is online

Users browsing this forum: komalrajsingh and 37 guests