how to Auto save for ((android game)) that contains levels

Hi this is my first question here :slight_smile:
So i’m making a platform game with levels (locked and unlocked levels) but i just can’t figure out how to save my game . like when i complete level 1 and unlock level 2 how to make the game auto save so when i come back level 1 and 2 still unlocked and the rest is locked .

i’m not talking about a save button … but an auto save

Thanks for helping out .

1 Like

An autosave function is the same than a save button, but is launched automatically every X seconds and/or after some events (completing a level, leveling-up).
The easiest way would be saving (through storage actions) the max level reached. At the beginning of the game you should read this max level value and unlock levels in function of it :slight_smile:

thank you for replying … ok but i don’t understand what is the (storage) in gdevelop and how to write that in events . can you give an example ?

In case you are using GD5, an example should be included I believe, if it not check out the link in my signature.
In case you are using GD4 I believe there is an example included called basic level editor I believe that has some save/load functionality.

i’m using gdevelop 5 and there is no tutorial for that … i have been trying for like 12 hours just to get it to work but i just don’t know how and i saw the file save/load example but it’s not related to my game . like i don’t even know if it is . i’m sorry i’m new to this . all i need is to save when a level is unlocked that’s it … but i can’t … that’s the only thing missing from the game . i guess i’m just gonna stop working on it i don’t know … anyway thanks for your help .

It is showing you how to save multiple things, essentially the entire level when you press the save button and then how to load all that info back when you press the load button. Now you might want to save a single value only if a level is unlocked to know how many levels are unlocked but that’s basically the same thing. Saving and loading a single value or multiple values makes no difference and when to save it or load it makes no difference either, only need to change the conditions.

No I can’t remember if anyone made a tutorial, As Lizard-13 mentioned, you need to use the storage action. I did explain all the options of the storage action here:
wiki.compilgames.net/doku.php/gd … -explained

Note, I may talking about file because I explained it for GD4 but in case of GD5 and HTML5 platform the storage action is using the web storage and not file but it should make no difference on your end regarding how to use the action you still need to use the same options as I described including the option for file.

Hope it helps somewhat.
Good luck.

1 Like

I did it finally . i was really starting to lose hope … thank you so much for your help … now i can auto save my game whenever the level is finished and also locked and unlocked levels is working perfectly … this is the best day of my life . now all i need to do is to finish the game and make more levels . nothing to worry about anymore i hope :slight_smile:

oh btw i have this little problem . the moving platform . when the player in on top of it . he is influenced by the gravity of the moving platform … like when the platform is moving up it gets hard to walk on the platform but when it’s going down the player just start floating or falling continuously when it’s moving left and right it can push the player in the air which looks weird so how do i fix that knowing that some levels have more than one moving platform ?

1 Like

So this will work on cookie clicker type game?

khaledali: regarding the movement platform, I don’t know for sure if it would work, but you could try a condition on collision of the platform that would set the x/y of the player to that of the platform, depending on what type of movement the platform is making.

I’m having a similar problem saving. I noticed that while GDevelop has lots of useful examples, one thing missing is a good old fashioned RPG. So I decided to work on a basic RPG template: it will need to have items, equipment, a battle system, user stats, and of course it would need a save/load function.

I’ve gotten just about everything figured out, minus whatever bugs crop up and some fine tuning, except for the save/load function. The project is available at itch.io if anyone wants to check it out or contribute anything. the password is oldschool (one word).

Here are screenshots of my save/load function.

I’ve looked over it and came up with 2 bugs. I wasn’t opening the storage before the save function, and there was a string being saved in a variable. So I fixed those two things, and it still didn’t work.

I did some more reading of the docs and I may have solved the problem. Object variables don’t persist across scenes. So I need to rewrite it using global variables and try again. Unfortunately I won’t have time until later this week.

I’m just wondering, as it’s on topic at the moment, if there’s any other reason that anyone else can see why this wouldn’t work, barring the two fixes mentioned above and swapping out the scene variables for global variables.