How do I save in local storage?

Get help using Construct 2

Post » Mon Jul 17, 2017 6:09 pm

Hi there,

I'm creating a little game with level select like angry birds.

To do this I follow step by step this tutorial ( to tell the truth I follow the original video tutorial because I don't mind to save highscore or collected stars; I want just the right animation on the sprite button of level select sheet) and all work fine; I just changed Go to layout event to manage multiple level selections.

https://www.scirra.com/TutorialViewFresh.aspx?ID=1160

The problem still saving using local storage considering also that I would make multiple worlds. At the end I will have 3 or 4 worlds with 12 levels each.

In the original old topic I commented explaining better what I'm trying to do attaching also an image to better understand.

Anyone can help me or share a capx example ?

Thanks in advance.
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 10:28 am

Guys nobody can help me ?
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 11:11 am

There are many tutorials to help you with saving to local storage. You are probably looking to save the MaxAchievedLevel global variable. Take a look at this tutorial and save this variable instead of Score. https://www.scirra.com/tutorials/9440/h ... al-storage
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Tue Jul 18, 2017 11:27 am

There was a similar tread about this which I helped solved, here is a link to that
viewtopic.php?f=147&t=192946&p=1130941#p1130941

Also here is a screenshot of my game, where I'm using local storage to save and load date with array saved as json
https://postimg.org/image/enyi4lp9x/

I hope this will help.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Tue Jul 18, 2017 1:20 pm

Hi there,

thanks for ther support.
Basically withouth having stars on animation buttons sprite on the selectlevel layout (after achieving a level) I were able to store data.

I try to explain : the player can take coin, gem, key (3 mandatory to go to next level) and has a score depending on enemies dead.

So these are all global variabiles in mine eventgame sheet but I don't mind to save.

Collectedstar (1 2 or 3) is a variable depending on score so, on how many enemies the player kills. At the moment score 5 = 1star 10 = 2stars 15 = 3stars

On Selectlevel event sheet I put an Array that says wich frame , locked or unlocked or animations 1star, 2star , 3star has to have the spritebutton. So it is an array with one dimension and 5 column. In the selectlevel event sheet I have also a global variable that is currentlevelA

When the player win, the action I put (in the event game sheet) in the array is: (line 49)

player win -> array : set value currentlevelA to max(2+CollectedStar,levels.At(currentlevelA))

I did all this following the video tut in the link I put above and all works fine I've just change somethings a little bit.

I think I have to save currentlevelA and apply animation to the frame using the array but I'm not able to do ?

@imhotep22 I see your example but you call also some functions and I do not understand very well what they do, then I think you use also array for levels and should be interesting understand how do this for multiworlds because now I'm thinking just to vreate different copy (not duplicate) of select level sheets for each world.

I put all the event for localstorage in the menuevent sheet because is the first of the app . I put also one event at the end of eventgame sheet to save currentlevelA data but it doesen't work (line 100) .

Can you please be so kind to check the apk?

Obviously it is a working in progress so just some levels bad done just to test. The player is at the end of layout so to finish fast.

https://drive.google.com/open?id=0B5PJd ... lMtNllRTDg

Thanks a lot.
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 1:48 pm

In the link of capx I share I see that (because I was testing) I insert also some event of local storage in the eventselectlevel sheet so delete it.
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 3:27 pm

Actually I created level system which is levels divided into areas 1,2 & 3 like world:
alextro wrote:Save system with star achievement: https://www.dropbox.com/s/vh3n39sk8z2dh ... .capx?dl=0
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Tue Jul 18, 2017 3:42 pm

@alextro thank you very much. I will check it asap

Best regards
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 6:06 pm

Hi there,

thank you very much again to all. At the end I understand how to store with array. Now all work great.

:)
B
9
S
3
G
2
Posts: 9
Reputation: 1,647

Post » Tue Jul 18, 2017 6:06 pm

Hi there,

thank you very much again to all. At the end I understand how to store with array. Now all work great.

:)
B
9
S
3
G
2
Posts: 9
Reputation: 1,647


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests