How do I save global variables? What am i doing wrong?

Get help using Construct 2

Post » Wed Sep 17, 2014 6:41 am

YES! I have read lots of topics about that, i also read manual and tutorial but i still can't do it.
I need to save global variables for my android game.
Could you please land a hand, what am i doing wrong or what is missing?

It is simple, when you complete a level and it needs to be saved when you open the game later.
I need it for all levels, without arrays if possible.
This took my 2 days and still i fail.

Image

pic link if you cant open picture above; http://imageshack.com/f/iqcLLDzZp
B
22
S
5
G
2
Posts: 210
Reputation: 3,377

Post » Wed Sep 17, 2014 7:38 am

you can use web storage,
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666

Post » Wed Sep 17, 2014 7:41 am

Yes i do, at least i try to do but i don't know what i am doing wrong...
B
22
S
5
G
2
Posts: 210
Reputation: 3,377

Post » Wed Sep 17, 2014 8:11 am

how about using the Save and load system
B
19
S
6
G
3
Posts: 197
Reputation: 4,154

Post » Wed Sep 17, 2014 8:14 am

it is too simple for this game and it will be my last choice if i can not make what i have in my mind, i just need variables to be stored then loaded when player runs game again.
B
22
S
5
G
2
Posts: 210
Reputation: 3,377

Post » Wed Sep 17, 2014 12:21 pm

I don't know what your game is, but I think your game will resume to the last level you played.

1.) You need a global variable which save the current level. (let's say the name is "CURRENT_LEVEL").

2.) then, everytime the player complete a level, check whether CURRENT_LEVEL is greater than (your_webstorage_key) or not. If yes, then add 1 to CURRENT_LEVEL, and save it to (your_webstorage_key).

3.) then, when your game is being opened, set CURRENT_LEVEL to (your_webstorage_key) to resume.

Sorry for my bad english.
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666

Post » Wed Sep 17, 2014 12:22 pm

and perhaps you need to learn "Progressive level selector". find it on google. :)
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666

Post » Wed Sep 17, 2014 12:32 pm

puntodamar wrote:I don't know what your game is, but I think your game will resume to the last level you played.

1.) You need a global variable which save the current level. (let's say the name is "CURRENT_LEVEL").

2.) then, everytime the player complete a level, check whether CURRENT_LEVEL is greater than (your_webstorage_key) or not. If yes, then add 1 to CURRENT_LEVEL, and save it to (your_webstorage_key).

3.) then, when your game is being opened, set CURRENT_LEVEL to (your_webstorage_key) to resume.

Sorry for my bad english.



Thank you, do i need to know about arrays? I think not. I will take a look at this
B
22
S
5
G
2
Posts: 210
Reputation: 3,377

Post » Wed Sep 17, 2014 5:18 pm

ok, goodluck then~
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests