How do I save game progress

Get help using Construct 2

Post » Wed Sep 23, 2015 9:50 am

Pls tell me friends
how to save game progress
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Sep 23, 2015 10:10 am

What do you actually mean with game progress? Just a few variables or/and the current position?
The easiest way would be the Save/Load SaveGame function. Otherwise use an array and save the array in the LocalStorage.

Regards
Image Image iTunes: Match3 | Google Play: Match3
B
106
S
39
G
31
Posts: 1,169
Reputation: 29,227

Post » Wed Sep 23, 2015 10:20 am

I have variables
.
i have level selection
.
i have character selection
.
.
pls tell me how could i save all these, for devices and desktops both
..
.
can you give me any example of doing this process

AndreasR wrote:What do you actually mean with game progress? Just a few variables or/and the current position?
The easiest way would be the Save/Load SaveGame function. Otherwise use an array and save the array in the LocalStorage.

Regards
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Sep 23, 2015 10:24 am

All your mentioned points are coverd by my Modular Game Template
https://www.scirra.com/store/royalty-fr ... plate-1287

There you find a way how to save progress with Arrays and LocalStorage.
I don't have a free example for that, sorry.

If you want to try it on your own, this tutorial will help you:
https://www.scirra.com/tutorials/1461/h ... age-plugin

Regards
Image Image iTunes: Match3 | Google Play: Match3
B
106
S
39
G
31
Posts: 1,169
Reputation: 29,227

Post » Wed Sep 23, 2015 10:36 am

i have already read this post
i have downloaded file too
.
your have use local storage for coins
but when i create sprite in your file and adding coins to variable it never saving its process
after reload
game starting from 0

may be m not getting proper
here is screenshot
dropbox.com/s/gkz6kdb06pfm7bn/sample%20copy.jpg?dl=0
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Sep 23, 2015 2:46 pm

luckyrawatlucky wrote:i have already read this post
i have downloaded file too
.
your have use local storage for coins
but when i create sprite in your file and adding coins to variable it never saving its process
after reload
game starting from 0

may be m not getting proper
here is screenshot
Image


Because your saving function is wrong.
You must use
LocalStorage - Set key 'playercoins_key' to playercoins

instead.

Regards
Image Image iTunes: Match3 | Google Play: Match3
B
106
S
39
G
31
Posts: 1,169
Reputation: 29,227

Post » Thu Sep 24, 2015 4:51 am

but this is totally your file that i have download
i have just added a bouncing ball and with every bouncing add 1 to player coin
.
i have done nothing with with this file
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Thu Sep 24, 2015 9:28 am

Yes, and the part you added is missing the fact of saving some informations.

The default capx does check on start of execution of the game if a key exists.
If it doesn't, it creates a default value and creates the key,
Otherwise, it sets a global variable value to the value contained in the key.

Then you added a modification of the global variable, but at no point did you save the value of this variable to the key.
So the modification is lost each time you execute the game and only loads the "default value" which is contained in the key.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
295
S
118
G
96
Posts: 7,327
Reputation: 71,246

Post » Thu Sep 24, 2015 10:09 am

@Kyatric
can you explain it in simple way
actually my English is not so gud
.
what does it mean
''but at no point did you save the value of this variable to the key.''
.
i have just add coins to check how its working
so pls tell me how can i add coins to variable


Kyatric wrote:Yes, and the part you added is missing the fact of saving some informations.

The default capx does check on start of execution of the game if a key exists.
If it doesn't, it creates a default value and creates the key,
Otherwise, it sets a global variable value to the value contained in the key.

Then you added a modification of the global variable, but at no point did you save the value of this variable to the key.
So the modification is lost each time you execute the game and only loads the "default value" which is contained in the key.
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Thu Sep 24, 2015 10:12 am

This means that you have to save the variable after each change of it.
I already mentioned above how you can save it. Jusr add this after you had updated the coins.

Regards
Image Image iTunes: Match3 | Google Play: Match3
B
106
S
39
G
31
Posts: 1,169
Reputation: 29,227

Next

Return to How do I....?

Who is online

Users browsing this forum: Akia410, Yahoo [Bot] and 9 guests