How do I save completed levels ?

Get help using Construct 2

Post » Sat Sep 06, 2014 10:24 am

fldr, have you achieved what you wanted to do on my file? The only thing who's missing is that part of my game :)
B
5
Posts: 11
Reputation: 247

Post » Sat Sep 06, 2014 1:13 pm

I'll explain what he was meant by using arrays, :).

Arrays store data in an orderly fashion, and you can call and insert data wherever you want. Arrays always start from 0, so the first spot for data is 0. To apply this to how you want to save data, you need to make an Array object. This is handy because you can store your level data in the order of levels, making it easy to select data and add it to an overall scoring list, for example. We'll call it array_name for ease of example, :). On the Array properties window you'll see a Width, Height and Depth. Width is the total amount of levels you want minus 1 (since it starts at 0, so 13 levels is 12 in the array), and it also represents X, whereas the Height and Depth represent Y and Z respectively. Once made, in an overall Event sheet (one you include on each local Event sheet for each layout) you need to click the following then read on:

System -> Set at X - NOTE: this is found under the Array section

Arrays can hold up to three parts of data in one section, for example 'array = [0,01,02], [1,11,12]'. Each has a X, Y, Z number, but you can use only the X, or the X and Y... totally up to what you need to store, but for what you want you just need X, so you use the above Event code for Set at X. For the X value, put the level number. For the value, put the score variable from that local Event sheet. Let's say the score variable is user_score and represents 16. You should now have the following Event code once you hit the Done button:

array_name -> Set value at 0 to user_score

The above score of user_score (16) is now set to be array_name[0] in terms of positioning. If you want to grab it from the array to have on the screen to check the score, all you have to do is have an element of your choice set the value to array_name.At(0) (0 is the X, if you had three, you'd need 0, 0, 0 or whatever positions you're wanting to grab) and it will retrieve it. That will retrieve the score which is 16 in this example.

Hope this helps!
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Sat Sep 06, 2014 2:02 pm

First of all, a big thank you for your answer inquiesco, but as "Arrays" and "WebStorage" are completely new elements for me, It's always difficult to realize the saving. I really wanted to know if there was ways for example, if you could modify the file which I put in download because I understand your explanations, but I don't arrive to execute them.

Thank you very much.
B
5
Posts: 11
Reputation: 247

Post » Fri Sep 19, 2014 5:19 pm

Hi, has anybody succeeded in changing my file? Please, this is the final stretch for my game.

Thank you !
B
5
Posts: 11
Reputation: 247

Previous

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 38 guests