How do I make a coin carry on to a map level selector

Get help using Construct 2

Post » Fri Oct 28, 2016 7:43 am

Hi. So this is a long term plan for my game but I want to be able to carry currency over the game, not just for each level/layouts. I ll try to explain what I need and hopefully someone can point me out the direction.

I will take one of my favourite games to explain this. Spyro the Dragon from PSX.

You collect gems on each level, and each level has different amount 100, 200, 400.. so you will see how many you have left in each level 80/100 lv1| 66/200 lv2 and so on. The gems carry over with you all game long, so you end up with over 10.000 gems and you use them to be able to travel worlds.

So basically I want to storage the total gems picked up and carry them all over the game layouts and track how manu do I have left in each layout to be indicated in a menu layout.

Does this sound possible? Thanks
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Fri Oct 28, 2016 2:27 pm

Shouldn't a global variable to store the amount do the job?
B
9
S
4
G
1
Posts: 32
Reputation: 871

Post » Fri Oct 28, 2016 2:54 pm

Walessio wrote:Shouldn't a global variable to store the amount do the job?


Yeah that's my thought but is not that simple. I figured a global variable will storage it, problem is how to set it up and how can you track each level...
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Fri Oct 28, 2016 3:38 pm

I guess that you can use a data dictonary to store each level's amount and use local storage to save/load this value when changing layout.
Take a look at this: https://www.scirra.com/manual/188/local-storage
B
9
S
4
G
1
Posts: 32
Reputation: 871

Post » Fri Oct 28, 2016 3:49 pm

I think you can connect it the way that your HUD displays to show it in-game or just make a separate layout with the information of gems. I think you can read it out with text (change looks later if wanted) and connect it to your global variable but for each level I think you need different variable.
I hope i helped with it.
B
11
S
2
G
1
Posts: 34
Reputation: 722

Post » Fri Oct 28, 2016 4:14 pm

If i understand correctly, you can use 2 arrays: one for amount on char, other for amount on the map. Each map/layout would be an index on your arrays. On your first array, the total variables is the total on your char.
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 113
Reputation: 3,231

Post » Sat Oct 29, 2016 12:22 pm

That sounds something hard to do. Could anyone provide a tutorial or example capx around?
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 31, 2016 10:23 pm

Bump. Hoping someone could help me out
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 31, 2016 11:00 pm

use a global variable, and never reset the global variables to default. also you can look into local storage for coins/valuables that should stack when you leave game. look for that in tutorial section.
B
75
S
22
G
68
Posts: 1,337
Reputation: 43,271

Post » Tue Nov 01, 2016 11:25 am

I guess I will try to investigate further. Thanks
B
14
S
5
Posts: 248
Reputation: 1,705


Return to How do I....?

Who is online

Users browsing this forum: David181, dop2000, jorgmaquoi, unicornspitfire and 35 guests