[SOLVED]Problem on level selection screen

Discussion and feedback on Construct 2

Post » Wed Sep 28, 2016 11:40 am

Hello everybody,

I made a mobile game for android with 2 of my friends.
Here's the link of the game ;
http://play.google.com/store/apps/detai ... es.TrapTap

But the problem is we want to save the game on each checkpoint. Actually not exactly "saving" the game. What we want is; for example if the player reaches level 3 and exits the game/shuts down the app and then opens it again we want the player can choose a level between level 1 to 3. I tried to make it with the help of Local Storage but it didn't work.

here's the event sheet of level 3
Image

and here's the event sheet of level selection screen

Image

What am i doing wrong ? Or is there any other way to do it ?

I hope i'm clear enough with the problem :D
Last edited by FCA on Wed Sep 28, 2016 2:46 pm, edited 1 time in total.
B
9
S
3
Posts: 3
Reputation: 633

Post » Wed Sep 28, 2016 12:04 pm

So, what exactly does the LevelCtr (global) value store? Does it store the amount of levels you have already played? Or the number of the level from which you quit the game last time?

I can see that you use the LocalStorage object correctly, I think the problem you are having is caused by the use of the variable. If you could tell us more about your LevelCtr variable, me might be able to solve your problem. :)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed Sep 28, 2016 12:15 pm

Thank you for your respond

It stores or what i wanted to do is make it store the max level you've reached. Like if you played the game till level 6 and then go back to main menu and choose level 3 the value of LevelCtr is 6

I can also upload everywhere i used LevelCtr variable in 2 hours if you want to take a look :)
B
9
S
3
Posts: 3
Reputation: 633

Post » Wed Sep 28, 2016 12:50 pm

So, if I understand you correctly, you don't need to change LevelCtr value when the level you choose is lower than the maximum level you reached right?

I would say that you need to get the LevelCtr from LocalStorage as soon as you start the game. That's probably the one and only time in your game where you should get the value from the LocalStorage, since the global variable "LevelCtr" isn't dependant on the LocalStorage Key.
You just need to check the LocalStorage Key when you start the game.

At the beginning of every level, you should check whether the current level's number is higher than the current LevelCtr and if that is the case, save the level's number as the LocalStorage "LevelCtr_Key".

Lastly, when the user quits the game, the current "LevelCtr" should be saved to the LocalStorage, in case, the "LevelCtr" variable has increased since the last change of the "LevelCtr_Key".

This should work, in theory.

Your images look like you don't have many events, so I'd be happy if you could provide me with a .capx so that I can refer to the event sheet context too. Thanks. :)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed Sep 28, 2016 2:41 pm

Thank you so much i solved the problem with help of you. And you also helped me to fully understand the whole Local Storage and Level Selection thing. :)

Btw the capx file is around 25 mb so solving the problem with no need to upload the capx file is another great thing :D
B
9
S
3
Posts: 3
Reputation: 633


Return to Construct 2 General

Who is online

Users browsing this forum: newt, rbailey83 and 25 guests