Save Game
tumble

Hello

 

I am making a game with the Wade Editor. I have several levels. I want to save the progress automatically so that when a level is completed, a save game file is created and the next time the player runs the game, they continue from there.

 

Is it possible? how?

1 Comment
foxcode

Hi tumble.

 

The solution you need here depends on exactly what save functionality you want. For instance, do you simply need to record what level the player got up to? Or are you trying to load an exact point in a level?

 

If you just want to store what level a player got up to, I suggest you take a look at the wade.storeLocalObject and wade.retrieveLocalObject functions. In javascript, there is no easy way to create save files to the hard drive. This is by design, as a script running on a random website should definitely not have the ability to modify data on your machine.

 

The local object functions however store data in the browser cache, which you can access later. I have not used these functions in a while but I will attempt a simple example.

 

var data = {onLevel:4, currentScore: 345};

wade.storeLocalObject("gameNameProgress", data); // This saves the object as a string to local storage

 

// Later when we come to get our data

 

var data = wade.retrieveLocalObject("gameNameProgress");

if(data)

{

    console.log(data);

}

 

 

I have a vague recollection that retrieveLocalObject might return an object that then contains the object you saved, I would try console logging what it returns, should be fairly straight forward.

 

I hope this helps. If you have any more questions or need more help, feel free to ask

Post a reply
Add Attachment
Submit Reply
Login to Reply