How do I automatically save game

Get help using Construct 2

Post » Thu Mar 05, 2015 11:15 am

I have title layout and game layout.
When i run my game at start system should load game and when i finish game layout system should save state.
Problem is when i set on start of layout 'load' game state this event will be looped at start of layout
B
114
S
29
G
48
Posts: 1,883
Reputation: 36,605

Post » Thu Mar 05, 2015 12:39 pm

You could create a "Loader layout" that will be the first layout of your project that will do the following:

[On start of layout] Load game

[On load failed] Go to 'TitleLayout' (if you play for the first time)

Also, if you save in GameLayout loading the game will bring you to that layout, but I am sure you want to make it start from the Title screen so add this condition to every eventsheet:

[On load complete] go to 'TitleLayout'

In this way you can save anywhere at anytime, just remember not to set that condition to the TitleLayout event sheet
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Thu Mar 05, 2015 2:35 pm

@BouncyTrip that make sense i will try. Thanks
B
114
S
29
G
48
Posts: 1,883
Reputation: 36,605

Post » Thu Mar 05, 2015 6:29 pm

Hmm, i have a question about this. Im creating a game with a bunch of things that can be upgraded and unlocked. Right now im using webstorage to get this done. But there are like 50 different variables that needs to be saved here and there. Can i just use this way instead? Does it work for Android games?
B
11
S
4
G
2
Posts: 116
Reputation: 1,936

Post » Thu Mar 05, 2015 6:56 pm

It works perfectly, but pay attention to performance, because I saw that loading my game made everything slower and I had to revert to webstorage...

***UPDATE*** I've just read that some "save" bugs were fixed on R197.
I reverted to webstorage when the last release was still R196, so I'll give a second chance to the save action :) , maybe those bugs were the performance killers.
Last edited by BouncyTrip on Fri Mar 06, 2015 1:58 am, edited 2 times in total.
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Thu Mar 05, 2015 7:14 pm

You can also use the "Function" object to save all those variables in webstorage.
give it a look:
https://www.scirra.com/manual/149/function

You just need to do the following:

[Function | "savemygame"] : (save all the variables in webstorage)

Then you can use that function as an action like this:

[On tap on SaveButton] : (call "savemygame")

The action (call "savemygame) will repeat all the actions defined in the [Function | "savemygame"]
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Fri Mar 06, 2015 10:54 am

Thanks @bouncytrip
guess i'll stick to webstorage then. Good idea with using functions to save variables. Never thought about that.
B
11
S
4
G
2
Posts: 116
Reputation: 1,936

Post » Fri Mar 06, 2015 12:44 pm

@DetteMan I'm gald to know I've been helpful :)

Also, I'm not sure but It seems you have to copy the function in every event sheet that will require to call that funciton.
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Fri Mar 06, 2015 1:22 pm

@BouncyTrip your idea works well for me, thanks
B
114
S
29
G
48
Posts: 1,883
Reputation: 36,605


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests