Saving Data Or Accounts

Is There Anything I Could Do To Have My Game Load Up To A Certain Point Like A Check Point So That People Won’t Have To Do It All Over Again?

First dont put caps in each word o_O
And second yes there is a way using window.localStorage

Change the name to what you want the save things to and change Value to what ever value you want the name to be

window.localStorage.setItem(“Name”,Value)
window.localStorage.getItem(“Name”)

Any questions?

3 Likes

could you reply with an example of what the code would look like

Sure here an example

Let give an example if player conpletes a level the game saves the data meaning when the player leaves the game and join back it will bring them back to where the last save was

Add this to update to what frame it is

if(project.player_lvl === 1){
change the ones to what ever lvl it is
window.localStorage.setItem(“Save_lvl”,1)
gotoAndStop(3) change the number 3 to what ever the frame is for lvl
}

Now let make a end goal, let add a object called endpoint and now make it so if the player hits the objective the project.player_lvl will go up.

Add this to update to what frame the lvl is

if(player.hits(endpoint)){
project.player_lvl = 1 change to what the lvl is
}

Now lets add it so it brings the player back

Add this to defualt in the first frame

project.save_lvl = window.getItem(“Save_lvl”)
if(project.save_lvl>=1){
if(project.save_lvl===1){
gotoAndStop(2)
}
if(project.save_lvl===2){
gotoAndStop(3)
}
Add more for more lvl
}

That should be it I think if you need me to make a wick file sure make sure to add a object name player else player.hit wont work and add it so it can move by adding this code to the update tab to the player.

if(isKeyDown(“w”){player.y-=5}
if(isKeyDown(“a”){player.x-=5}
if(isKeyDown(“s”){player.y+=5}
if(isKeyDown(“d”){player.x+=5}

1 Like

i sort of understand but if could please make a .wick file as an example so i could get a better idea of what the code looks like that would be helpful. EDIT (also im making a quiz game so if you could try to make the code compatible that would be better.)

Here some more example using cookies and/or local storage
Second link is an actual application using previously saved data